confused about apigateway authorization #3076
Replies: 10 comments
-
ok, i got it
the “Authorizers:” name (CustomAuthorizer) in the template for AWS::Serverless::Api has to match the authorizer name in the openapi spec for the path:
and in the openapi spec securitySchemes:
|
Beta Was this translation helpful? Give feedback.
-
so, that still leaves me with one question: why does DefaultAuthorizer seem to override everything? |
Beta Was this translation helpful? Give feedback.
-
and is there some clever way to copy the name that needs to be repeated from the sam template into the openapi spec? |
Beta Was this translation helpful? Give feedback.
-
ok, so i think i figured out the DefaultAuthorizer. if it is used in the template for the api gateway:
then, for noauth endpoints, in BOTH the template
and the openapi, the security must be NONE
|
Beta Was this translation helpful? Give feedback.
-
so, i still have a problem, https://editor.swagger.io/ gives this openapi a syntax error:
but, it likes this syntax:
however, with the 2nd syntax & a DefaultAuthorizer in the template, every endpoint gets the default Authorizer |
Beta Was this translation helpful? Give feedback.
-
@autohandle Thank you! Your findings helped a lot 🚀 |
Beta Was this translation helpful? Give feedback.
-
@autohandle Thank you! You saved @pflorek and me a lot of debugging and googling ❤️ |
Beta Was this translation helpful? Give feedback.
-
@autohandle Thank you! You made our day 🔥 |
Beta Was this translation helpful? Give feedback.
-
Hi thanks for the deep dive. We have recently also noticed that there's a bug when users are using We've introduced a fix to this problem by specifying OverrideApiAuth. See example:
|
Beta Was this translation helpful? Give feedback.
-
i created a template using helloworld & i created 2 functions:
get /auth
get /noauth
i made an api gateway with a custom authorizer:
this worked and i can see the authorizer on the Amazon API Gateway screen

then i added a DefinitionBody to the api gateway:
and created an openapi for the endpoints
but, when i (re)visit the api gateway console, the authorizer is gone:

actually, it seems to be controlled by the DefaultAuthorizer in the 'AWS::Serverless::Api', if the default is on, they both have an authorizer and if it is commented out, neither does.
Beta Was this translation helpful? Give feedback.
All reactions