-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
When using an inline swagger, api+method+path authorizers do not get added #650
Comments
We plan on adding a feature to merge your defined Swagger with the generated Swagger from SAM. This should resolve this issue also. |
A workaround exists where if the name of the This is often what is desired, because if you have security requirements for the endpoint, you probably want to define them (as best you can) in the swagger doc. SAM snippet below: myApi:
Type: AWS::Serverless::Api
Properties:
EndpointConfiguration: REGIONAL
StageName: master
DefinitionBody:
swagger: '2.0'
info:
title: Test
version: 1.0.0
description: Only a test
schemes:
- https
paths:
"/sayHello":
get:
operationId: hello
description: Says "Hello"
produces:
- text/html
responses:
'200':
description: OK
default:
description: Error
security:
- keyAuth: [] # refers to security definition in this swagger doc
x-amazon-apigateway-integration:
uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${Function.Arn}/invocations
httpMethod: POST
type: aws_proxy
securityDefinitions:
keyAuth: #matches name of Auth/Authorizer defined on the Api
description: Authentication will be performed using a custom authenticator
type: apiKey
name: Authorization
in: header
Auth:
Authorizers:
keyAuth: # Name of this authorizer; becomes the name of the authorizer in API Gateway console
Identity:
Headers:
- Authorization
ReauthorizeEvery: 600
FunctionPayloadType: REQUEST
FunctionArn: !Ref CustomAuthArn The result of the above is that the authorizer is created with expected properties in the API, and the endpoint is configured to use that authorizer. Untested are the effects of setting the |
This solution worked perfectly for me. Thank you! |
Consider the following example, when custom swagger definition is commented out, the API resource has custom authorizer configured. When the comments are removed, it seems that we ignore the generated swagger definition and use custom swagger definition, which caused this problem.
Will bring this up and discuss with the team. |
Introducing
#2943 |
Description:
My expectation was that when using the
Auth
functionality in SAM against an API and Function, when no defaultauthorizer is configured then the Authorizer would be assigned against the Functions path
I've also noticed that when using a Default Authorizer, all methods on the API get the Authorizer assigned, configuring
NONE
authorizer against an API Event does not prevent the authorizer getting assigned.Steps to reproduce the issue:
Given a SAM Template that includes a an inline swagger document, an Authorizer and Auth configured on the DELETE and
POST events
template.yaml
example/service.py
example/__init__.py
Deploy this SAM Template
Observed result:
No Authorizers are assigned to any of the methods
Expected result:
My expectation was that the GET Methods on the path
/
and/{id}
would not have an authorizer assigned, butPOST /
andDELETE /{id}
do not have authorizer assignedThe text was updated successfully, but these errors were encountered: