【发布时间】:2019-03-30 19:54:39
【问题描述】:
我正在尝试在我的 .Net Core Web API 应用上设置一个已经存在的授权函数。 当我使用纯 aws lambda nodejs 时,.yml 文件来完成它,看起来像这样:
custom:
defaultStage: test
currentStage: ${opt:stage, self:custom.defaultStage}
defaultRegion: us-east-1
currentRegion: ${opt:region, self:custom.defaultRegion}
**defaultAuthorizer**: us-east-1:xxxxxxxx:function:TypeToken-test-Authorizer
**currentAuthorizer**: ${opt:authorizer, self:custom.defaultAuthorizer}
provider:
name: aws
runtime: nodejs6.10
stage: ${self:custom.currentStage}
profile: ${opt:profile, "default"}
region: ${self:custom.currentRegion}
functions:
MyFunctionName:
handler: handlerTestAPI.myFunctionName
events:
- http:
path: myFunctionName
method: post
cors: true
integration: lambda
**authorizer:**
arn: arn:aws:lambda:${self:custom.currentAuthorizer}
resultTtlInSeconds: 0
identitySource: method.request.header.Authorization
type: token
对于这种情况,ASP.NET Core App serverless.template 文件类似于:
"Resources" : {
"AspNetCoreFunction" : {
"Type" : "AWS::Serverless::Function",
"Properties": {
"Handler": "Test.API::Project.API.LambdaEntryPoint::FunctionHandlerAsync",
"Runtime": "dotnetcore2.1",
"CodeUri": "",
"MemorySize": 256,
"Timeout": 30,
"Role": null,
"Policies": [ "AWSLambdaFullAccess" ],
"Environment" : {
"Variables" : {
"TestTable" : { "Fn::If" : ["CreateProjectTable", {"Ref":"ProjectTable"}, { "Ref" : "ProjectTableName" } ] }
}
},
"Events": {
"PutResource": {
"Type": "Api",
"Properties": {
"Path": "/{proxy+}",
"Method": "ANY"
}
}
}
}
}
我已经搜索了使用 serverless.template 文件在 .net 核心无服务器功能之上设置现有授权方的模板,但还没有找到。
感谢您的反馈。
【问题讨论】:
标签: .net amazon-web-services asp.net-core aws-lambda asp.net-core-webapi