Class TokenAuthorizer
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.
Inherited Members
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class TokenAuthorizer : Authorizer, IResource, IAuthorizer
Syntax (vb)
Public Class TokenAuthorizer
Inherits Authorizer
Implements IResource, IAuthorizer
Remarks
Based on the token, authorization is performed by a lambda function.
Resource: AWS::ApiGateway::Authorizer
ExampleMetadata: infused
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
});
Synopsis
Constructors
TokenAuthorizer(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
TokenAuthorizer(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
TokenAuthorizer(Construct, String, ITokenAuthorizerProps) |
Properties
AuthorizerArn | The ARN of the authorizer to be used in permission policies, such as IAM and resource-based grants. |
AuthorizerId | The id of the authorizer. |
AuthorizerProps | |
Handler | The Lambda function handler that this authorizer uses. |
RestApiId | |
Role | The IAM role that the API Gateway service assumes while invoking the Lambda function. |
Methods
LazyRestApiId() | Returns a token that resolves to the Rest Api Id at the time of synthesis. |
SetupPermissions() | Sets up the permissions necessary for the API Gateway service to invoke the Lambda function. |
Constructors
TokenAuthorizer(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected TokenAuthorizer(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
TokenAuthorizer(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected TokenAuthorizer(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
TokenAuthorizer(Construct, String, ITokenAuthorizerProps)
public TokenAuthorizer(Construct scope, string id, ITokenAuthorizerProps props)
Parameters
- scope Constructs.Construct
- id System.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
System.String
AuthorizerId
The id of the authorizer.
public override string AuthorizerId { get; }
Property Value
System.String
Overrides
AuthorizerProps
Handler
The Lambda function handler that this authorizer uses.
protected virtual IFunction Handler { get; }
Property Value
RestApiId
protected virtual string RestApiId { get; set; }
Property Value
System.String
Role
The IAM role that the API Gateway service assumes while invoking the Lambda function.
protected virtual IRole Role { get; }
Property Value
Methods
LazyRestApiId()
Returns a token that resolves to the Rest Api Id at the time of synthesis.
protected virtual string LazyRestApiId()
Returns
System.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()