Commit 6f95af8f by Oleksandr Barabash

additional loggers added

parent 25a2083d
......@@ -88,20 +88,36 @@ class TokenHelper:
""" Check if token is Valid """
from config import Auth
Log.d(__name__, "is_token_valid")
# split first
header_b64_str, body_b64_str, signature = token.split(".")
token_unsigned = "{}.{}".format(header_b64_str, body_b64_str)
Log.d(__name__, "header_b64_str, body_b64_str, signature:"
"{}, {}, {}".format(header_b64_str, body_b64_str,
signature))
# parse
header = json_loads(b64decode_str(header_b64_str))
body = json_loads(b64decode_str(body_b64_str))
Log.d(__name__, "token header: {}".format(header))
Log.d(__name__, "token body: {}".format(body))
# check fields
token_typ = header.get("typ", None)
token_alg = header.get("alg", None)
token_kid = header.get("kid", None)
token_sub = body.get("sub", None)
token_exp = body.get("exp", None)
Log.d(__name__, "token_typ, token_alg, token_kid,"
"token_sub, token_exp: "
"{}, {}, {}, {}, {}".format(token_typ, token_alg,
token_kid, token_sub,
token_exp))
if None in [token_typ, token_alg, token_kid, token_sub, token_exp]:
return False
......@@ -146,8 +162,6 @@ class TokenHelper:
a_type, a_value = parse_auth_header(
request.headers.get("Authorization")
)
Log.i(__name__, "auth_headers:: headers: "
"'{}'".format(request.headers))
Log.i(__name__, "auth_headers:: type: '{}'".format(a_type))
if a_type == Auth.TYPE and self.is_token_valid(a_value):
return await f(request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment