interface RequestAuthorizerProps
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.APIGateway.RequestAuthorizerProps |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#RequestAuthorizerProps |
![]() | software.amazon.awscdk.services.apigateway.RequestAuthorizerProps |
![]() | aws_cdk.aws_apigateway.RequestAuthorizerProps |
![]() | aws-cdk-lib » aws_apigateway » RequestAuthorizerProps |
Properties for RequestAuthorizer.
Example
declare const authFn: lambda.Function;
declare const books: apigateway.Resource;
const auth = new apigateway.RequestAuthorizer(this, 'booksAuthorizer', {
handler: authFn,
identitySources: [apigateway.IdentitySource.header('Authorization')]
});
books.addMethod('GET', new apigateway.HttpIntegration('http://amazon.com'), {
authorizer: auth
});
Properties
Name | Type | Description |
---|---|---|
handler | IFunction | The handler for the authorizer lambda function. |
identity | string[] | An array of request header mapping expressions for identities. |
assume | IRole | An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer. |
authorizer | string | An optional human friendly name for the authorizer. |
results | Duration | How long APIGateway should cache the results. |
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.
identitySources
Type:
string[]
An array of request header mapping expressions for identities.
Supported parameter types are
Header, Query String, Stage Variable, and Context. For instance, extracting an authorization
token from a header would use the identity source IdentitySource.header('Authorization')
.
Note: API Gateway uses the specified identity sources as the request authorizer caching key. When caching is enabled, API Gateway calls the authorizer's Lambda function only after successfully verifying that all the specified identity sources are present at runtime. If a specified identify source is missing, null, or empty, API Gateway returns a 401 Unauthorized response without calling the authorizer Lambda function.
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.
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.