Description
With aws_api_gateway_method.authorization = "NONE", API Gateway does not authenticate the caller. This can suit public content or CORS preflight.
Potential impact
Without other controls, callers may read private data, make changes or generate backend costs. Check the resource policy and backend authorization as well.
Remediation
Use IAM, Cognito or a Lambda authorizer on protected methods. Limit the permitted actions, redeploy to the intended stage and verify that only authorized calls succeed. For intentionally public methods, configure the appropriate access policy, usage limits and audit logs.
Examples
The second excerpt changes the same GET to CUSTOM and sets authorizer_id. Supply the API, resource with its path parameter, integration, Lambda authorizer and invocation permission.
Before
resource "aws_api_gateway_method" "example" {
rest_api_id = aws_api_gateway_rest_api.this.id
resource_id = aws_api_gateway_resource.this.id
http_method = "GET"
authorization = "NONE"
request_parameters = {
"method.request.path.proxy" = true
}
}
After
resource "aws_api_gateway_method" "example" {
rest_api_id = aws_api_gateway_rest_api.this.id
resource_id = aws_api_gateway_resource.this.id
http_method = "GET"
authorization = "CUSTOM"
authorizer_id = aws_api_gateway_authorizer.this.id
request_parameters = {
"method.request.path.proxy" = true
}
}