Review API Gateway method authentication

Apply caller authentication and operation-specific permissions to methods that need protection.

Description

AuthorizationType: NONE leaves caller authentication off for that method. Determine which methods serve public content or CORS preflight and which require protection.

Potential impact

Without a resource policy or backend authorization, unintended callers may read or change data. Unnecessary requests can also increase load and cost.

Remediation

Protect the required methods with AWS_IAM, Cognito or a Lambda authorizer. Limit each caller to the actions and resources they need. Deploy to the intended stage and verify that permitted calls succeed and others are denied.

Examples

The excerpts show two separate unauthenticated methods. OPTIONS can handle CORS preflight. To protect GET, change that method itself. The API and integration settings are omitted.

Before

yaml
Resources:
  MockMethod:
    Type: AWS::ApiGateway::Method
    Properties:
      RestApiId: !Ref MyApi
      ResourceId: !GetAtt MyApi.RootResourceId
      HttpMethod: GET
      AuthorizationType: NONE

After

yaml
Resources:
  CorsOptionsMethod:
    Type: AWS::ApiGateway::Method
    Properties:
      RestApiId: !Ref MyApi
      ResourceId: !GetAtt MyApi.RootResourceId
      HttpMethod: OPTIONS
      AuthorizationType: NONE

References