Token based lambda authorizer that recognizes the caller's identity as a bearer token, such as a JSON Web Token (JWT) or an OAuth token. Based on the token, authorization is performed by a lambda function.
import { TokenAuthorizer } from 'aws-cdk-lib/aws-apigateway';Or use the module namespace:
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
// apigateway.TokenAuthorizerConfiguration passed to the constructor as TokenAuthorizerProps.
identitySourceOptionalstringThe 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')`
validationRegexOptionalstringAn 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.
LambdaAuthorizerPropshandlerRequiredinherited from LambdaAuthorizerPropsIFunctionThe 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](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-input.html) and [output specification](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html).
assumeRoleOptionalinherited from LambdaAuthorizerPropsIRoleAn 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.
authorizerNameOptionalinherited from LambdaAuthorizerPropsstringAn optional human friendly name for the authorizer. Note that, this is not the primary identifier of the authorizer.
Default: - the unique construct ID
resultsCacheTtlOptionalinherited from LambdaAuthorizerPropsDurationHow long APIGateway should cache the results. Max 1 hour. Disable caching by setting this to 0.
Default: - Duration.minutes(5)
Everything you need to know about Amazon API Gateway on one page. HD quality, print-friendly.
Download Free Infographicaws-apigateway