1

In lambda authorizer, the http status code returned for access denied, token expired etc are 403. How do i return a message 'Token Expired' in case the Token Expires.

context.fail method is not supported. Raise Exception only creates log in cloudwatch.

def lambda_handler(event, context):
    .
    .
    .
    # verify the signature
    claims = jwt.get_unverified_claims(token)
    if time.time() > claims['exp']:
        print('Token is expired')
        return generatePolicy(claims['sub'], 'Deny', event['methodArn'])
    else:
    if(claims['cognito:groups'][0].lower()=='admin'):
        return generatePolicy(claims['sub'], 'Allow', event['methodArn'])
    else:
        return generatePolicy(claims['sub'], 'Deny', event['methodArn'])
    return claims
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.