[英]How to add non authenticated routes in AWS SAM template
So this is my SAM template:所以这是我的 SAM 模板:
webApi:
Type: AWS::Serverless::Api
Properties:
Auth:
DefaultAuthorizer: CognitoAuthorizer
Authorizers:
CognitoAuthorizer:
UserPoolArn: !GetAtt myUserPool.Arn
AddDefaultAuthorizerToCorsPreflight: false
Cors:
AllowMethods: "'*'"
AllowHeaders: "'*'"
AllowOrigin: "'*'"
StageName: !Ref Environment
DefinitionBody:
swagger: "2.0"
info:
title:
Ref: AWS::StackName
paths:
/path/one:
post:
responses: {}
x-amazon-apigateway-integration:
uri: myFunction.Arn
httpMethod: "POST"
type: "aws_proxy"
/path/two:
post:
responses: {}
x-amazon-apigateway-integration:
uri: myFunction.Arn
httpMethod: "POST"
type: "aws_proxy"
How can I make the path/two
an non authenticated route?如何使
path/two
成为非认证路由? I tried to google but there was nothing.我试着用谷歌搜索,但什么也没有。
If possible I don't want to create another API Gateway.如果可能,我不想创建另一个 API 网关。 I would like to do it within the same resource.
我想在同一资源内进行。
As OpenAPI, you can use security: []
to disable auth in some path.作为 OpenAPI,您可以使用
security: []
来禁用某些路径中的身份验证。
Refer:参考:
https://github.com/zalando/connexion/issues/944 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-body https://github.com/zalando/connexion/issues/944 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html#cfn-apigateway-restapi-body
In AWS SAM template, to disable security for specific endpoints in the DefinitionBody
, what worked for me is the following:在 AWS SAM 模板中,要禁用
DefinitionBody
中特定端点的安全性,对我有用的是以下内容:
swagger: "2.0"
info:
title:
Ref: AWS::StackName
paths:
/path/one:
post:
security:
- NONE: []
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.