[utils] Add `jwt_decode_hs256`

Code from #1340
Authored by: Ashish0804
This commit is contained in:
pukkandan 2021-10-28 02:07:15 +05:30
parent 5be76d1ab7
commit 16b0d7e621
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698
1 changed files with 7 additions and 0 deletions

View File

@ -6512,6 +6512,13 @@ def jwt_encode_hs256(payload_data, key, headers={}):
return token return token
# can be extended in future to verify the signature and parse header and return the algorithm used if it's not HS256
def jwt_decode_hs256(jwt):
header_b64, payload_b64, signature_b64 = jwt.split('.')
payload_data = json.loads(base64.urlsafe_b64decode(payload_b64))
return payload_data
def supports_terminal_sequences(stream): def supports_terminal_sequences(stream):
if compat_os_name == 'nt': if compat_os_name == 'nt':
if get_windows_version() < (10, 0, 10586): if get_windows_version() < (10, 0, 10586):