TokenAuthorizerProps Struct
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
});
# auth_fn: lambda.Function
# books: apigateway.Resource
auth = apigateway.TokenAuthorizer(self, "booksAuthorizer",
handler=auth_fn
)
books.add_method("GET", apigateway.HttpIntegration("http://amazon.com"),
authorizer=auth
)
Function authFn;
Resource books;
TokenAuthorizer auth = TokenAuthorizer.Builder.create(this, "booksAuthorizer")
.handler(authFn)
.build();
books.addMethod("GET", new HttpIntegration("http://amazon.com"), MethodOptions.builder()
.authorizer(auth)
.build());
// Install: dotnet add package Amazon.CDK.Lib
Function authFn;
Resource books;
var auth = new TokenAuthorizer(this, "booksAuthorizer", new TokenAuthorizerProps {
Handler = authFn
});
books.AddMethod("GET", new HttpIntegration("http://amazon.com"), new MethodOptions {
Authorizer = auth
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var authFn Function
var books Resource
auth := apigateway.NewTokenAuthorizer(this, jsii.String("booksAuthorizer"), &TokenAuthorizerProps{
Handler: authFn,
})
books.AddMethod(jsii.String("GET"), apigateway.NewHttpIntegration(jsii.String("http://amazon.com")), &MethodOptions{
Authorizer: auth,
})
Properties
assumeRoleoptionalIRoleassume_roleoptionalIRoleassumeRoleoptionalIRoleAssumeRoleoptionalIRoleAssumeRoleoptionalIRole#Default: A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.
The IAM role must be assumable by 'apigateway.amazonaws.com'.
authorizerNameoptionalstringauthorizer_nameoptionalstrauthorizerNameoptionalStringAuthorizerNameoptionalstringAuthorizerNameoptional*string#Default: the unique construct ID
Note that, this is not the primary identifier of the authorizer.
notes
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.
identitySourceoptionalstringidentity_sourceoptionalstridentitySourceoptionalStringIdentitySourceoptionalstringIdentitySourceoptional*string#Default: IdentitySource.header('Authorization')
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.
resultsCacheTtloptionalDurationresults_cache_ttloptionalDurationresultsCacheTtloptionalDurationResultsCacheTtloptionalDurationResultsCacheTtloptionalDuration= Duration.minutes(5)#Max 1 hour. Disable caching by setting this to 0.
validationRegexoptionalstringvalidation_regexoptionalstrvalidationRegexoptionalStringValidationRegexoptionalstringValidationRegexoptional*string#Default: no regex filter will be applied.
When matched the authorizer lambda is invoked, otherwise a 401 Unauthorized is returned to the client.