Class TokenAuthorizer

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.apigateway.Authorizer
software.amazon.awscdk.services.apigateway.TokenAuthorizer
All Implemented Interfaces:
IResource, IAuthorizer, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.101.0 (build b95fe5d)", date="2024-07-22T22:42:46.729Z") @Stability(Stable) public class TokenAuthorizer extends Authorizer implements IAuthorizer
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.

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

Example:

 Function authFn;
 Resource books;
 TokenAuthorizer auth = TokenAuthorizer.Builder.create(this, "booksAuthorizer")
         .handler(authFn)
         .build();
 books.addMethod("GET", new HttpIntegration("http://amazon.com"), MethodOptions.builder()
         .authorizer(auth)
         .build());
 
  • Constructor Details

    • TokenAuthorizer

      protected TokenAuthorizer(software.amazon.jsii.JsiiObjectRef objRef)
    • TokenAuthorizer

      protected TokenAuthorizer(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • TokenAuthorizer

      @Stability(Stable) public TokenAuthorizer(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TokenAuthorizerProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • lazyRestApiId

      @Stability(Stable) @NotNull protected String lazyRestApiId()
      Returns a token that resolves to the Rest Api Id at the time of synthesis.

      Throws an error, during token resolution, if no RestApi is attached to this authorizer.

    • setupPermissions

      @Stability(Stable) protected void setupPermissions()
      Sets up the permissions necessary for the API Gateway service to invoke the Lambda function.
    • getAuthorizerArn

      @Stability(Stable) @NotNull public String getAuthorizerArn()
      The ARN of the authorizer to be used in permission policies, such as IAM and resource-based grants.
    • getAuthorizerId

      @Stability(Stable) @NotNull public String getAuthorizerId()
      The id of the authorizer.
      Specified by:
      getAuthorizerId in interface IAuthorizer
      Specified by:
      getAuthorizerId in class Authorizer
    • getAuthorizerProps

      @Stability(Stable) @NotNull protected CfnAuthorizerProps getAuthorizerProps()
    • getHandler

      @Stability(Stable) @NotNull protected IFunction getHandler()
      The Lambda function handler that this authorizer uses.
    • getRole

      @Stability(Stable) @Nullable protected IRole getRole()
      The IAM role that the API Gateway service assumes while invoking the Lambda function.
    • getRestApiId

      @Stability(Stable) @Nullable protected String getRestApiId()
    • setRestApiId

      @Stability(Stable) protected void setRestApiId(@Nullable String value)