aws-cdk-lib.aws_apigateway.TokenAuthorizerProps

interface TokenAuthorizerProps

LanguageType name
.NETAmazon.CDK.AWS.APIGateway.TokenAuthorizerProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#TokenAuthorizerProps
Javasoftware.amazon.awscdk.services.apigateway.TokenAuthorizerProps
Pythonaws_cdk.aws_apigateway.TokenAuthorizerProps
TypeScript (source)aws-cdk-lib » aws_apigateway » TokenAuthorizerProps

Properties for TokenAuthorizer.

Example

declare const authFn: lambda.Function;
declare const books: apigateway.Resource;

const auth = new apigateway.TokenAuthorizer(this, 'booksAuthorizer', {
  handler: authFn
});

books.addMethod('GET', new apigateway.HttpIntegration('http://amazon.com'), {
  authorizer: auth
});

Properties

NameTypeDescription
handlerIFunctionThe handler for the authorizer lambda function.
assumeRole?IRoleAn optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.
authorizerName?stringAn optional human friendly name for the authorizer.
identitySource?stringThe request header mapping expression for the bearer token.
resultsCacheTtl?DurationHow long APIGateway should cache the results.
validationRegex?stringAn optional regex to be matched against the authorization token.

handler

Type: 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.


assumeRole?

Type: IRole (optional, default: A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.)

An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.

The IAM role must be assumable by 'apigateway.amazonaws.com'.


authorizerName?

Type: string (optional, default: the unique construct ID)

An optional human friendly name for the authorizer.

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


identitySource?

Type: string (optional, default: IdentitySource.header('Authorization'))

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.

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


resultsCacheTtl?

Type: Duration (optional, default: Duration.minutes(5))

How long APIGateway should cache the results.

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


validationRegex?

Type: string (optional, default: no regex filter will be applied.)

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.