Aws serverless:每个功能一个授权者

问题描述 投票:0回答:0

我正在使用 AWS + Serverless + JS,我不想为每个函数单独定义授权方。你有什么建议来解决这个问题?

service: iot-server-2
frameworkVersion: '3'

provider:
  name: aws
  runtime: nodejs18.x
  httpApi:
    authorizers:
      customAuthorizer:
        type: request
        functionName: authorizerFunc

functions:
  api:
    handler: index.handler
    events:
      - httpApi:
          path: /
          method: get
          authorizer:      <-- I DON'T WANT THIS HERE
            name: customAuthorizer
  getDevice:
      handler: sensor-save-data-handler.handler
      events:
        - httpApi:
            path: /sensors
            method: get
            authorizer:     <-- I DON'T WANT THIS HERE
              name: customAuthorizer

  authorizerFunc:
    handler: authorizer.handler
amazon-web-services authentication serverless
© www.soinside.com 2019 - 2024. All rights reserved.