Open anderson-0 opened 1 year ago
@anderson-0 Hello, I have same problem, maybe you can watch this link
@anderson-0 Hello, I find how to define the custom authorizer. You can define an authorizer lambda, then define securitySchemes
in open API file like this:
components:
securitySchemes:
myAuthorizer:
type: apiKey
in: header
name: Authorization
x-amazon-apigateway-authtype: custom
x-amazon-apigateway-authorizer:
type: token
authorizerUri:
arn:aws:apigateway:<AWS-Region>:lambda:path/2015-03-31/functions/<AuthorizerARN>/invocations
authorizerResultTtlInSeconds: 0
Then you can use this myAuthorizer
in every endpoint:
/test/v1:
get:
responses:
'200':
$ref: '#/components/responses/Standard200EmptyResponse'
x-amazon-apigateway-integration:
httpMethod: POST
uri:
<LambdaARN>
responses:
default:
statusCode: '200'
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
passthroughBehavior: when_no_match
contentHandling: CONVERT_TO_TEXT
type: aws_proxy
security:
- myAuthorizer: []
One limitation that I am facing is that for the generated API gateway based on the openapi spec I would like to add an existing lambda function that exists in my serverless.yml.
For example, I have this lambda that check for authorization:
I've also added the code required by the package like below:
And the resource section:
I've tried to add an api gateway authorizer like below:
But even with that it generates my api gateway without adding this lambda as the authorizer. Can you tell me if this is supported in any way by the package?