public static final class TokenAuthorizer.Builder
extends java.lang.Object
TokenAuthorizer
.Modifier and Type | Method and Description |
---|---|
TokenAuthorizer.Builder |
assumeRole(IRole assumeRole)
An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.
|
TokenAuthorizer.Builder |
authorizerName(java.lang.String authorizerName)
An optional human friendly name for the authorizer.
|
TokenAuthorizer |
build() |
static TokenAuthorizer.Builder |
create(software.constructs.Construct scope,
java.lang.String id) |
TokenAuthorizer.Builder |
handler(IFunction handler)
The handler for the authorizer lambda function.
|
TokenAuthorizer.Builder |
identitySource(java.lang.String identitySource)
The request header mapping expression for the bearer token.
|
TokenAuthorizer.Builder |
resultsCacheTtl(Duration resultsCacheTtl)
How long APIGateway should cache the results.
|
TokenAuthorizer.Builder |
validationRegex(java.lang.String validationRegex)
An optional regex to be matched against the authorization token.
|
public static TokenAuthorizer.Builder create(software.constructs.Construct scope, java.lang.String id)
scope
- This parameter is required.id
- This parameter is required.TokenAuthorizer.Builder
.public TokenAuthorizer.Builder handler(IFunction handler)
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}.
handler
- The handler for the authorizer lambda function. This parameter is required.this
public TokenAuthorizer.Builder assumeRole(IRole assumeRole)
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.
assumeRole
- An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer. This parameter is required.this
public TokenAuthorizer.Builder authorizerName(java.lang.String authorizerName)
Note that, this is not the primary identifier of the authorizer.
Default: - the unique construcrt ID
authorizerName
- An optional human friendly name for the authorizer. This parameter is required.this
public TokenAuthorizer.Builder resultsCacheTtl(Duration resultsCacheTtl)
Max 1 hour. Disable caching by setting this to 0.
Default: Duration.minutes(5)
resultsCacheTtl
- How long APIGateway should cache the results. This parameter is required.this
public TokenAuthorizer.Builder identitySource(java.lang.String identitySource)
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')`
identitySource
- The request header mapping expression for the bearer token. This parameter is required.this
public TokenAuthorizer.Builder validationRegex(java.lang.String validationRegex)
When matched the authorizer lambda is invoked, otherwise a 401 Unauthorized is returned to the client.
Default: - no regex filter will be applied.
validationRegex
- An optional regex to be matched against the authorization token. This parameter is required.this
public TokenAuthorizer build()