Class RequestAuthorizer
- Namespace
- Amazon.CDK.AWS.APIGateway
- Assembly
- Amazon.CDK.AWS.APIGateway.dll
Request-based lambda authorizer that recognizes the caller's identity via request parameters, such as headers, paths, query strings, stage variables, or context variables.
public class RequestAuthorizer : Authorizer, IAuthorizer
- Inheritance
-
RequestAuthorizer
- Implements
- Inherited Members
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
});
Remarks
Based on the request, authorization is performed by a lambda function.
Resource: AWS::ApiGateway::Authorizer
ExampleMetadata: infused
Constructors
RequestAuthorizer(Construct, string, IRequestAuthorizerProps)
public RequestAuthorizer(Construct scope, string id, IRequestAuthorizerProps props)
Parameters
scope
Constructid
stringprops
IRequestAuthorizerProps
Properties
AuthorizerArn
The ARN of the authorizer to be used in permission policies, such as IAM and resource-based grants.
public virtual string AuthorizerArn { get; }
Property Value
AuthorizerId
The id of the authorizer.
public override string AuthorizerId { get; }
Property Value
Handler
The Lambda function handler that this authorizer uses.
protected virtual IFunction Handler { get; }
Property Value
- IFunction
RestApiId
protected virtual string? RestApiId { get; set; }
Property Value
Role
The IAM role that the API Gateway service assumes while invoking the Lambda function.
protected virtual IRole? Role { get; }
Property Value
- IRole
Methods
LazyRestApiId()
Returns a token that resolves to the Rest Api Id at the time of synthesis.
protected virtual string LazyRestApiId()
Returns
Remarks
Throws an error, during token resolution, if no RestApi is attached to this authorizer.
SetupPermissions()
Sets up the permissions necessary for the API Gateway service to invoke the Lambda function.
protected virtual void SetupPermissions()