Class RequestAuthorizerProps
Properties for RequestAuthorizer.
Inheritance
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class RequestAuthorizerProps : Object, IRequestAuthorizerProps, ILambdaAuthorizerProps
Syntax (vb)
Public Class RequestAuthorizerProps
Inherits Object
Implements IRequestAuthorizerProps, ILambdaAuthorizerProps
Remarks
ExampleMetadata: infused
Examples
Function authFn;
Resource books;
var auth = new RequestAuthorizer(this, "booksAuthorizer", new RequestAuthorizerProps {
Handler = authFn,
IdentitySources = new [] { IdentitySource.Header("Authorization") }
});
books.AddMethod("GET", new HttpIntegration("http://amazon.com"), new MethodOptions {
Authorizer = auth
});
Synopsis
Constructors
RequestAuthorizerProps() |
Properties
AssumeRole | An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer. |
AuthorizerName | An optional human friendly name for the authorizer. |
Handler | The handler for the authorizer lambda function. |
IdentitySources | An array of request header mapping expressions for identities. |
ResultsCacheTtl | How long APIGateway should cache the results. |
Constructors
RequestAuthorizerProps()
public RequestAuthorizerProps()
Properties
AssumeRole
An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.
public IRole AssumeRole { get; set; }
Property Value
Remarks
The IAM role must be assumable by 'apigateway.amazonaws.com'.
Default: - A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.
AuthorizerName
An optional human friendly name for the authorizer.
public string AuthorizerName { get; set; }
Property Value
System.String
Remarks
Note that, this is not the primary identifier of the authorizer.
Default: - the unique construct ID
Handler
The handler for the authorizer lambda function.
public IFunction Handler { get; set; }
Property Value
Remarks
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
An array of request header mapping expressions for identities.
public string[] IdentitySources { get; set; }
Property Value
System.String[]
Remarks
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.
ResultsCacheTtl
How long APIGateway should cache the results.
public Duration ResultsCacheTtl { get; set; }
Property Value
Remarks
Max 1 hour. Disable caching by setting this to 0.
Default: - Duration.minutes(5)