Table of Contents

Class TokenAuthorizer

Namespace
Amazon.CDK.AWS.APIGateway
Assembly
Amazon.CDK.AWS.APIGateway.dll

Token based lambda authorizer that recognizes the caller's identity as a bearer token, such as a JSON Web Token (JWT) or an OAuth token.

public class TokenAuthorizer : Authorizer, IAuthorizer
Inheritance
TokenAuthorizer
Implements
Inherited Members

Examples

Function authFn;
             Resource books;


             var auth = new TokenAuthorizer(this, "booksAuthorizer", new TokenAuthorizerProps {
                 Handler = authFn
             });

             books.AddMethod("GET", new HttpIntegration("http://amazon.com"), new MethodOptions {
                 Authorizer = auth
             });

Remarks

Based on the token, authorization is performed by a lambda function.

Resource: AWS::ApiGateway::Authorizer

ExampleMetadata: infused

Constructors

TokenAuthorizer(Construct, string, ITokenAuthorizerProps)

public TokenAuthorizer(Construct scope, string id, ITokenAuthorizerProps props)

Parameters

scope Construct
id string
props ITokenAuthorizerProps

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

string

AuthorizerId

The id of the authorizer.

public override string AuthorizerId { get; }

Property Value

string

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

string

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

string

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()