interface HttpLambdaAuthorizerProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.APIGatewayv2.Authorizers.HttpLambdaAuthorizerProps |
Java | software.amazon.awscdk.services.apigatewayv2.authorizers.HttpLambdaAuthorizerProps |
Python | aws_cdk.aws_apigatewayv2_authorizers.HttpLambdaAuthorizerProps |
TypeScript (source) | @aws-cdk/aws-apigatewayv2-authorizers » HttpLambdaAuthorizerProps |
Properties to initialize HttpTokenAuthorizer.
Example
import { HttpLambdaAuthorizer, HttpLambdaResponseType } from '@aws-cdk/aws-apigatewayv2-authorizers';
import { HttpUrlIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
// This function handles your auth logic
declare const authHandler: lambda.Function;
const authorizer = new HttpLambdaAuthorizer('BooksAuthorizer', authHandler, {
responseTypes: [HttpLambdaResponseType.SIMPLE], // Define if returns simple and/or iam response
});
const api = new apigwv2.HttpApi(this, 'HttpApi');
api.addRoutes({
integration: new HttpUrlIntegration('BooksIntegration', 'https://get-books-proxy.myproxy.internal'),
path: '/books',
authorizer,
});
Properties
Name | Type | Description |
---|---|---|
authorizer | string | Friendly authorizer name. |
identity | string[] | The identity source for which authorization is requested. |
response | Http [] | The types of responses the lambda can return. |
results | Duration | How long APIGateway should cache the results. |
authorizerName?
Type:
string
(optional, default: same value as id
passed in the constructor.)
Friendly authorizer name.
identitySource?
Type:
string[]
(optional, default: ['$request.header.Authorization'])
The identity source for which authorization is requested.
responseTypes?
Type:
Http
[]
(optional, default: [HttpLambdaResponseType.IAM])
The types of responses the lambda can return.
If HttpLambdaResponseType.SIMPLE is included then response format 2.0 will be used.
resultsCacheTtl?
Type:
Duration
(optional, default: Duration.minutes(5))
How long APIGateway should cache the results.
Max 1 hour.
Disable caching by setting this to Duration.seconds(0)
.