serverless/serverless

Move `http` event authorizer settings to top level `provider` section

Open

#2,887 创建于 2016年12月7日

在 GitHub 查看
 (14 评论) (2 反应) (0 负责人)JavaScript (46,915 star) (5,734 fork)batch import
bug/designcat/aws-event-api-gatewayhelp wanted

描述

Currently, the settings for a custom authorizer function are set within the event settings for each function:

functions:
  newFunction:
    handler: function.handler
    events:
      -  http:
            path: url/path
            method: get
            authorizer:
              name: customAuth
              resultTtlInSeconds: 30
              identityValidationExpression: .*

  customAuth:
    handler: auth.handler
    memorySize: 128

This leaves room for those settings to be redefined multiple times in the configuration, and can introduce uncertainty, particularly when there are multiple hands touching the code.

It would be beneficial to have everything related to the custom authorizer in one spot, and just reference the authorizer by name in each function. Something like this:

functions:
  newFunction:
    handler: function.handler
    events:
      -  http:
            path: url/path
            method: get
            authorizer: customAuth

  customAuth:
    handler: auth.handler
    memorySize: 128
    authorizerSettings:
      resultTtlInSeconds: 30
      identityValidationExpression: .*

Implementation proposal

Introduce similar authorizer configuration as it's for httpApi events. Individual authorizers should be configured at provider.apiGateway.authorizer settings and which are referenced at http events.

This new setup should be introduced in non breaking way, but with configured deprecation of authorizer configurations at http event level

贡献者指南