【问题标题】:Serverless framework AWS ApiGateway v2 authorizers无服务器框架 AWS ApiGateway v2 授权方
【发布时间】:2020-08-21 23:03:41
【问题描述】:

我正在尝试基于此doc 设置简单的授权方。还使用无服务器插件serverless-pseudo-parameters

我的授权者无服务器配置:

provider:
...
  logs:
    httpApi: true
  httpApi:
    cors: true
    authorizers:
      simpleAuthorizer:
        identitySource: $request.header.Authorization
        issuerUrl:
          - Fn::Join:
              - '/'
              - - https://cognito-idp.#{AWS::Region}.amazonaws.com
                - "#{CognitoUserPool}"
        audience:
          - "#CognitoUserPoolClient"

我对简单 lambda 的配置:

functions:
  ping:
    name: ${self:provider.stage}-ping
    handler: test.handler
    events:
      - httpApi:
          method: GET
          path: /test
          authorizer:
            name: simpleAuthorizer

我的用户池和用户池客户端的配置:

resources:
  Resources:
    CognitoUserPool:
      Type: AWS::Cognito::UserPool
      Properties:
        UserPoolName: ${self:service}-${self:provider.stage}-user
        UsernameAttributes:
          - email
        Policies:
          PasswordPolicy:
            MinimumLength: 6
            RequireLowercase: False
            RequireNumbers: True
            RequireSymbols: False
            RequireUppercase: True
        Schema:
          - Name: email
            Required: false
            DeveloperOnlyAttribute: false
            Mutable: true
            AttributeDataType: String

    CognitoUserPoolClient:
      Type: AWS::Cognito::UserPoolClient
      Properties:
        ClientName: cognito-example-client
        GenerateSecret: False
        UserPoolId: "#{CognitoUserPool}"

用户池、用户池客户端、HTTP API、lambda 成功创建,但我在 API Gateway 服务的 AWS 控制台上看不到授权方。

【问题讨论】:

    标签: amazon-web-services aws-api-gateway amazon-cognito serverless-framework


    【解决方案1】:

    因此,问题有简单的解决方案:只需更新您的无服务器(我使用了 1.63.0,这给了我这个问题)。

    【讨论】:

      猜你喜欢
      • 2020-11-08
      • 2019-05-01
      • 2019-05-08
      • 1970-01-01
      • 1970-01-01
      • 2017-12-13
      • 1970-01-01
      • 2020-02-05
      • 2018-08-27
      相关资源
      最近更新 更多