Exemple #1
0
def get_token_details(token, tenant_id=None):
    try:
        token_details = json.loads(aes.decode_aes(base64.b64decode(token)))
    except (TypeError, ValueError):
        raise exceptions.Unauthorized('Invalid Key')

    if time.time() > token_details['expires']:
        raise exceptions.Unauthorized('Expired Key')

    if tenant_id and str(token_details['tenant_id']) != tenant_id:
        raise exceptions.Unauthorized('Tenant/token Mismatch')

    return token_details
Exemple #2
0
 def token_from_id(self, token_id):
     try:
         return json.loads(aes.decode_aes(base64.b64decode(token_id)))
     except (TypeError, ValueError):
         raise exceptions.InvalidTokenError('Malformed token')
Exemple #3
0
 def token_from_id(self, token_id):
     try:
         return json.loads(aes.decode_aes(base64.b64decode(token_id)))
     except (TypeError, ValueError):
         raise exceptions.InvalidTokenError('Malformed token')