RequestAuthorizerProps
- class aws_cdk.aws_apigateway.RequestAuthorizerProps(*, handler, assume_role=None, authorizer_name=None, results_cache_ttl=None, identity_sources)
Bases:
LambdaAuthorizerProps
Properties for RequestAuthorizer.
- Parameters:
handler (
IFunction
) – The handler for the authorizer lambda function. The handler must follow a very specific protocol on the input it receives and the output it needs to produce. API Gateway has documented the handler’s input specification and output specification.assume_role (
Optional
[IRole
]) – An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer. The IAM role must be assumable by ‘apigateway.amazonaws.com’. Default: - A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.authorizer_name (
Optional
[str
]) – An optional human friendly name for the authorizer. Note that, this is not the primary identifier of the authorizer. Default: - the unique construct IDresults_cache_ttl (
Optional
[Duration
]) – How long APIGateway should cache the results. Max 1 hour. Disable caching by setting this to 0. Default: - Duration.minutes(5)identity_sources (
Sequence
[str
]) – An array of request header mapping expressions for identities. Supported parameter types are Header, Query String, Stage Variable, and Context. For instance, extracting an authorization token from a header would use the identity sourceIdentitySource.header('Authorization')
. Note: API Gateway uses the specified identity sources as the request authorizer caching key. When caching is enabled, API Gateway calls the authorizer’s Lambda function only after successfully verifying that all the specified identity sources are present at runtime. If a specified identify source is missing, null, or empty, API Gateway returns a 401 Unauthorized response without calling the authorizer Lambda function.
- ExampleMetadata:
infused
Example:
# auth_fn: lambda.Function # books: apigateway.Resource auth = apigateway.RequestAuthorizer(self, "booksAuthorizer", handler=auth_fn, identity_sources=[apigateway.IdentitySource.header("Authorization")] ) books.add_method("GET", apigateway.HttpIntegration("http://amazon.com"), authorizer=auth )
Attributes
- assume_role
An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.
The IAM role must be assumable by ‘apigateway.amazonaws.com’.
- Default:
A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.
- authorizer_name
An optional human friendly name for the authorizer.
Note that, this is not the primary identifier of the authorizer.
- Default:
the unique construct ID
- handler
The handler for the authorizer lambda function.
The handler must follow a very specific protocol on the input it receives and the output it needs to produce. API Gateway has documented the handler’s input specification and output specification.
- identity_sources
An array of request header mapping expressions for identities.
Supported parameter types are Header, Query String, Stage Variable, and Context. For instance, extracting an authorization token from a header would use the identity source
IdentitySource.header('Authorization')
.Note: API Gateway uses the specified identity sources as the request authorizer caching key. When caching is enabled, API Gateway calls the authorizer’s Lambda function only after successfully verifying that all the specified identity sources are present at runtime. If a specified identify source is missing, null, or empty, API Gateway returns a 401 Unauthorized response without calling the authorizer Lambda function.
- results_cache_ttl
How long APIGateway should cache the results.
Max 1 hour. Disable caching by setting this to 0.
- Default:
Duration.minutes(5)