MCPcopy Create free account
hub / github.com/StackStorm/st2 / validate_token_and_source

Function validate_token_and_source

st2common/st2common/util/auth.py:63–86  ·  view source on GitHub ↗

Validate the provided authentication token. :param token_in_headers: Authentication token provided via headers. :type token_in_headers: ``str`` :param token_in_query_params: Authentication token provided via query params. :type token_in_query_params: ``str`` :return: Toke

(token_in_headers, token_in_query_params)

Source from the content-addressed store, hash-verified

61
62
63def validate_token_and_source(token_in_headers, token_in_query_params):
64 """
65 Validate the provided authentication token.
66
67 :param token_in_headers: Authentication token provided via headers.
68 :type token_in_headers: ``str``
69
70 :param token_in_query_params: Authentication token provided via query params.
71 :type token_in_query_params: ``str``
72
73 :return: TokenDB object on success.
74 :rtype: :class:`.TokenDB`
75 """
76 if not token_in_headers and not token_in_query_params:
77 LOG.audit("Token is not found in header or query parameters.")
78 raise exceptions.TokenNotProvidedError("Token is not provided.")
79
80 if token_in_headers:
81 LOG.audit("Token provided in headers")
82
83 if token_in_query_params:
84 LOG.audit("Token provided in query parameters")
85
86 return validate_token(token_in_headers or token_in_query_params)
87
88
89def generate_api_key():

Callers

nothing calls this directly

Calls 1

validate_tokenFunction · 0.85

Tested by

no test coverage detected