feat(chalice): changed authorizer
This commit is contained in:
parent
b68c954aff
commit
3543c97054
1 changed files with 3 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue