feat(chalice): changed authorizer

This commit is contained in:
Taha Yassine Kraiem 2022-10-12 17:15:11 +02:00
parent b68c954aff
commit 3543c97054

View file

@ -16,7 +16,7 @@ def jwt_authorizer(token):
token[1],
config("jwt_secret"),
algorithms=config("jwt_algorithm"),
audience=[f"plugin:{helper.get_stage_name()}", f"front:{helper.get_stage_name()}"]
audience=[f"front:{helper.get_stage_name()}"]
)
except jwt.ExpiredSignatureError:
print("! JWT Expired signature")
@ -38,13 +38,12 @@ def jwt_context(context):
}
def generate_jwt(id, tenant_id, iat, aud, exp=None):
def generate_jwt(id, tenant_id, iat, aud):
token = jwt.encode(
payload={
"userId": id,
"tenantId": tenant_id,
"exp": iat // 1000 + int(config("JWT_EXP_DELTA_SECONDS")) + TimeUTC.get_utc_offset() // 1000 \
if exp is None else exp+ TimeUTC.get_utc_offset() // 1000,
"exp": iat // 1000 + config("JWT_EXPIRATION", cast=int) + TimeUTC.get_utc_offset() // 1000,
"iss": config("JWT_ISSUER"),
"iat": iat // 1000,
"aud": aud