0

我已经使用共享授权方方法有一段时间了,就像这里所说的那样-> https://www.serverless.com/framework/docs/providers/aws/events/apigateway#share-authorizer

我将自定义身份验证建立为 lambda,然后使用 API 网关将其作为资源输出:

CustomGatewayAuthorizer:
  handler: path/to/handler.authorizer
  name:${self:provider.stage}-Gateway-Authorizer-Lambda
  provisionedConcurrency: 1
  warmup:
    default:
      concurrency: 1
      enabled: true
  concurrencyAutoscaling:
    enabled: true
    maximum: 50
    minimum: 1
    usage: 0.85
    scaleInCooldown: 120
    scaleOutCooldown: 360

Resources:
  ApiGateway:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: ${self:provider.stage}-Gateway-ApiGateway
      MinimumCompressionSize: 0 # Enabled for all responses.

  APIGatewayAuthorizer:
    Type: AWS::ApiGateway::Authorizer
    Properties:
      AuthorizerUri: 'arn:aws:apigateway:#{AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:provider.stage}-Gateway-Authorizer-Lambda/invocations'
      Type: REQUEST
      IdentitySource: method.request.header.User-Agent
      AuthorizerResultTtlInSeconds: 1
      Name: ApiGatewayAuthorizer
      RestApiId:
        Ref: NemlApiGateway

Outputs:
  apiGatewayAuthorizer:
    Description: Shared custom Gateway authorizer
    Value:
      Ref: APIGatewayAuthorizer
    Export:
      Name: ${self:provider.stage}-Gateway-Authorizer

一切正常,但是当在我的其他端点中多次引用身份验证时,它会停止将 API 网关作为触发器附加,因此会破坏身份验证。

有谁知道我可以引用共享授权人的次数是否有限制?我在文档或其他论坛中没有找到任何解决方案。

4

0 回答 0