TokenAuthorizerProps

class aws_cdk.aws_apigateway.TokenAuthorizerProps(*, handler, assume_role=None, authorizer_name=None, results_cache_ttl=None, identity_source=None, validation_regex=None)

Bases: aws_cdk.aws_apigateway.LambdaAuthorizerProps

__init__(*, handler, assume_role=None, authorizer_name=None, results_cache_ttl=None, identity_source=None, validation_regex=None)

Properties for TokenAuthorizer.

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 {@link https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html | here} and output specification {@link https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html | here}.

  • 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: this.node.uniqueId

  • results_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_source (Optional[str]) – The request header mapping expression for the bearer token. This is typically passed as part of the header, in which case this should be method.request.header.Authorizer where Authorizer is the header containing the bearer token. Default: IdentitySource.header('Authorization')

  • validation_regex (Optional[str]) – An optional regex to be matched against the authorization token. When matched the authorizer lambda is invoked, otherwise a 401 Unauthorized is returned to the client. Default: - no regex filter will be applied.

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 :default: - A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.

Return type

Optional[IRole]

authorizer_name

An optional human friendly name for the authorizer.

Note that, this is not the primary identifier of the authorizer.

default :default: this.node.uniqueId

Return type

Optional[str]

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 {@link https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html | here} and output specification {@link https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html | here}.

Return type

IFunction

identity_source

The request header mapping expression for the bearer token.

This is typically passed as part of the header, in which case this should be method.request.header.Authorizer where Authorizer is the header containing the bearer token.

default :default: IdentitySource.header('Authorization')

see :see: https://docs.aws.amazon.com/apigateway/api-reference/link-relation/authorizer-create/#identitySource

Return type

Optional[str]

results_cache_ttl

How long APIGateway should cache the results.

Max 1 hour. Disable caching by setting this to 0.

default :default: Duration.minutes(5)

Return type

Optional[Duration]

validation_regex

An optional regex to be matched against the authorization token.

When matched the authorizer lambda is invoked, otherwise a 401 Unauthorized is returned to the client.

default :default: - no regex filter will be applied.

Return type

Optional[str]