WebSocketLambdaAuthorizer
- class aws_cdk.aws_apigatewayv2_authorizers.WebSocketLambdaAuthorizer(id, handler, *, authorizer_name=None, identity_source=None)
Bases:
object
Authorize WebSocket Api routes via a lambda function.
- ExampleMetadata:
infused
Example:
from aws_cdk.aws_apigatewayv2_authorizers import WebSocketLambdaAuthorizer from aws_cdk.aws_apigatewayv2_integrations import WebSocketLambdaIntegration # This function handles your auth logic # auth_handler: lambda.Function # This function handles your WebSocket requests # handler: lambda.Function authorizer = WebSocketLambdaAuthorizer("Authorizer", auth_handler) integration = WebSocketLambdaIntegration("Integration", handler) apigwv2.WebSocketApi(self, "WebSocketApi", connect_route_options=apigwv2.WebSocketRouteOptions( integration=integration, authorizer=authorizer ) )
- Parameters:
id (
str
) –handler (
IFunction
) –authorizer_name (
Optional
[str
]) – The name of the authorizer. Default: - same value asid
passed in the constructor.identity_source (
Optional
[Sequence
[str
]]) – The identity source for which authorization is requested. Request parameter match'route.request.querystring|header.[a-zA-z0-9._-]+'
. Staged variable match'stageVariables.[a-zA-Z0-9._-]+'
. Context parameter match'context.[a-zA-Z0-9._-]+'
. Default: [‘route.request.header.Authorization’]
Methods
- bind(*, route, scope)
Bind this authorizer to a specified WebSocket route.
- Parameters:
route (
IWebSocketRoute
) – The route to which the authorizer is being bound.scope (
Construct
) – The scope for any constructs created as part of the bind.
- Return type: