HttpLambdaAuthorizerProps

class aws_cdk.aws_apigatewayv2_authorizers.HttpLambdaAuthorizerProps(*, authorizer_name=None, identity_source=None, response_types=None, results_cache_ttl=None)

Bases: object

Properties to initialize HttpTokenAuthorizer.

Parameters:
  • authorizer_name (Optional[str]) – Friendly authorizer name. Default: - same value as id passed in the constructor.

  • identity_source (Optional[Sequence[str]]) – The identity source for which authorization is requested. Default: [‘$request.header.Authorization’]

  • response_types (Optional[Sequence[HttpLambdaResponseType]]) – The types of responses the lambda can return. If HttpLambdaResponseType.SIMPLE is included then response format 2.0 will be used. Default: [HttpLambdaResponseType.IAM]

  • results_cache_ttl (Optional[Duration]) – How long APIGateway should cache the results. Max 1 hour. Disable caching by setting this to Duration.seconds(0). Default: Duration.minutes(5)

ExampleMetadata:

infused

Example:

from aws_cdk.aws_apigatewayv2_authorizers import HttpLambdaAuthorizer, HttpLambdaResponseType
from aws_cdk.aws_apigatewayv2_integrations import HttpUrlIntegration

# This function handles your auth logic
# auth_handler: lambda.Function


authorizer = HttpLambdaAuthorizer("BooksAuthorizer", auth_handler,
    response_types=[HttpLambdaResponseType.SIMPLE]
)

api = apigwv2.HttpApi(self, "HttpApi")

api.add_routes(
    integration=HttpUrlIntegration("BooksIntegration", "https://get-books-proxy.example.com"),
    path="/books",
    authorizer=authorizer
)

Attributes

authorizer_name

Friendly authorizer name.

Default:
  • same value as id passed in the constructor.

identity_source

The identity source for which authorization is requested.

Default:

[‘$request.header.Authorization’]

response_types

The types of responses the lambda can return.

If HttpLambdaResponseType.SIMPLE is included then response format 2.0 will be used.

Default:

[HttpLambdaResponseType.IAM]

See:

https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html#http-api-lambda-authorizer.payload-format-response

results_cache_ttl

How long APIGateway should cache the results.

Max 1 hour. Disable caching by setting this to Duration.seconds(0).

Default:

Duration.minutes(5)