Class: AWSCDK::APIGateway::TokenAuthorizerProps
- Inherits:
-
LambdaAuthorizerProps
- Object
- LambdaAuthorizerProps
- AWSCDK::APIGateway::TokenAuthorizerProps
- Defined in:
- api_gateway/token_authorizer_props.rb
Overview
Properties for TokenAuthorizer.
Instance Attribute Summary collapse
-
#assume_role ⇒ AWSCDK::IAM::IRole?
readonly
An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.
-
#authorizer_name ⇒ String?
readonly
An optional human friendly name for the authorizer.
-
#handler ⇒ AWSCDK::Lambda::IFunction
readonly
The handler for the authorizer lambda function.
-
#identity_source ⇒ String?
readonly
The request header mapping expression for the bearer token.
-
#results_cache_ttl ⇒ AWSCDK::Duration?
readonly
How long APIGateway should cache the results.
-
#validation_regex ⇒ String?
readonly
An optional regex to be matched against the authorization token.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(handler:, assume_role: nil, authorizer_name: nil, results_cache_ttl: nil, identity_source: nil, validation_regex: nil) ⇒ TokenAuthorizerProps
constructor
A new instance of TokenAuthorizerProps.
- #to_jsii ⇒ Object
Constructor Details
#initialize(handler:, assume_role: nil, authorizer_name: nil, results_cache_ttl: nil, identity_source: nil, validation_regex: nil) ⇒ TokenAuthorizerProps
Returns a new instance of TokenAuthorizerProps.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'api_gateway/token_authorizer_props.rb', line 13 def initialize(handler:, assume_role: nil, authorizer_name: nil, results_cache_ttl: nil, identity_source: nil, validation_regex: nil) @handler = handler Jsii::Type.check_type(@handler, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhLklGdW5jdGlvbiJ9")), "handler") @assume_role = assume_role Jsii::Type.check_type(@assume_role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "assumeRole") unless @assume_role.nil? @authorizer_name = Jsii::Type.check_type(@authorizer_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "authorizerName") unless @authorizer_name.nil? @results_cache_ttl = results_cache_ttl Jsii::Type.check_type(@results_cache_ttl, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "resultsCacheTtl") unless @results_cache_ttl.nil? @identity_source = identity_source Jsii::Type.check_type(@identity_source, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "identitySource") unless @identity_source.nil? @validation_regex = validation_regex Jsii::Type.check_type(@validation_regex, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "validationRegex") unless @validation_regex.nil? end |
Instance Attribute Details
#assume_role ⇒ AWSCDK::IAM::IRole? (readonly)
Default: - A resource policy is added to the Lambda function allowing apigateway.amazonaws.com to invoke the function.
An optional IAM role for APIGateway to assume before calling the Lambda-based authorizer.
The IAM role must be assumable by 'apigateway.amazonaws.com'.
44 45 46 |
# File 'api_gateway/token_authorizer_props.rb', line 44 def assume_role @assume_role end |
#authorizer_name ⇒ String? (readonly)
Default: - the unique construct ID
An optional human friendly name for the authorizer.
Note that, this is not the primary identifier of the authorizer.
51 52 53 |
# File 'api_gateway/token_authorizer_props.rb', line 51 def @authorizer_name end |
#handler ⇒ AWSCDK::Lambda::IFunction (readonly)
The handler for the authorizer lambda function.
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.
36 37 38 |
# File 'api_gateway/token_authorizer_props.rb', line 36 def handler @handler end |
#identity_source ⇒ String? (readonly)
Default: IdentitySource.header('Authorization')
The request header mapping expression for the bearer token.
This is typically passed as part of the header, in which case
this should be method.request.header.Authorizer where Authorizer is the header containing the bearer token.
68 69 70 |
# File 'api_gateway/token_authorizer_props.rb', line 68 def identity_source @identity_source end |
#results_cache_ttl ⇒ AWSCDK::Duration? (readonly)
Default: - Duration.minutes(5)
How long APIGateway should cache the results.
Max 1 hour. Disable caching by setting this to 0.
59 60 61 |
# File 'api_gateway/token_authorizer_props.rb', line 59 def results_cache_ttl @results_cache_ttl end |
#validation_regex ⇒ String? (readonly)
Default: - no regex filter will be applied.
An optional regex to be matched against the authorization token.
When matched the authorizer lambda is invoked, otherwise a 401 Unauthorized is returned to the client.
76 77 78 |
# File 'api_gateway/token_authorizer_props.rb', line 76 def validation_regex @validation_regex end |
Class Method Details
.jsii_properties ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'api_gateway/token_authorizer_props.rb', line 78 def self.jsii_properties { :handler => "handler", :assume_role => "assumeRole", :authorizer_name => "authorizerName", :results_cache_ttl => "resultsCacheTtl", :identity_source => "identitySource", :validation_regex => "validationRegex", } end |
Instance Method Details
#to_jsii ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'api_gateway/token_authorizer_props.rb', line 89 def to_jsii result = {} result.merge!(super) result.merge!({ "handler" => @handler, "assumeRole" => @assume_role, "authorizerName" => @authorizer_name, "resultsCacheTtl" => @results_cache_ttl, "identitySource" => @identity_source, "validationRegex" => @validation_regex, }) result.compact end |