Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect failure mechanism from aws-python-auth0-custom-authorizers-api #305

Open
edeca opened this issue Oct 9, 2018 · 0 comments
Open

Comments

@edeca
Copy link
Contributor

edeca commented Oct 9, 2018

I used the aws-python-auth0-custom-authorizers-api example as the basis for a lambda function.

The AWS documentation says this about the expected return from an authorizer:

A Lambda authorizer function's output must include the principal identifier (principalId) and a policy document (policyDocument) containing a list of policy statements.

In the AWS example Python authorizer it details how to handle failure:

you can send a 401 Unauthorized response to the client by failing like so:
raise Exception('Unauthorized')

In a few places the example returns create_401_response(), which returns status_code, headers and body.

When debugging my custom code this seems to cause an AuthorizerConfigurationException, as seen in the HTTP response headers:

x-amzn-errortype: AuthorizerConfigurationException
x-cache: Error from cloudfront

Using the API Gateway authorizer tester I get a few more debugging messages:

Mon Oct 08 21:43:07 UTC 2018 : Execution failed due to configuration error: Invalid JSON in response: {"statusCode": 401, "headers": {"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Credentials": true}, "body": "\"Unauthorized\""}
Mon Oct 08 21:43:07 UTC 2018 : AuthorizerConfigurationException

So I think the options should be:

  • For invalid authentication, raise Exception('Unauthorized')
  • For valid users with no access (e.g. RBAC), return generate_policy(None, 'Deny', event['methodArn'])
  • For valid users with permissions, return an allow policy.
This was referenced Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant