Class: AWSCDK::APIGateway::CfnAuthorizerProps

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
api_gateway/cfn_authorizer_props.rb

Overview

Properties for defining a CfnAuthorizer.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, rest_api_id:, type:, authorizer_credentials: nil, authorizer_result_ttl_in_seconds: nil, authorizer_uri: nil, auth_type: nil, identity_source: nil, identity_validation_expression: nil, provider_arns: nil) ⇒ CfnAuthorizerProps

Returns a new instance of CfnAuthorizerProps.

Parameters:

  • name (String)

    The name of the authorizer.

  • rest_api_id (String, AWSCDK::Interfaces::AWSApigateway::IRestAPIRef)

    The string identifier of the associated RestApi.

  • type (String)

    The authorizer type.

  • authorizer_credentials (String, AWSCDK::Interfaces::AWSIAM::IRoleRef, nil) (defaults to: nil)

    Specifies the required credentials as an IAM role for API Gateway to invoke the authorizer.

  • authorizer_result_ttl_in_seconds (Numeric, nil) (defaults to: nil)

    The TTL in seconds of cached authorizer results.

  • authorizer_uri (String, nil) (defaults to: nil)

    Specifies the authorizer's Uniform Resource Identifier (URI).

  • auth_type (String, nil) (defaults to: nil)

    Optional customer-defined field, used in OpenAPI imports and exports without functional impact.

  • identity_source (String, nil) (defaults to: nil)

    The identity source for which authorization is requested.

  • identity_validation_expression (String, nil) (defaults to: nil)

    A validation expression for the incoming identity token.

  • provider_arns (Array<String, AWSCDK::Interfaces::AWSCognito::IUserPoolRef>, nil) (defaults to: nil)

    A list of the Amazon Cognito user pool ARNs for the COGNITO_USER_POOLS authorizer.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'api_gateway/cfn_authorizer_props.rb', line 19

def initialize(name:, rest_api_id:, type:, authorizer_credentials: nil, authorizer_result_ttl_in_seconds: nil, authorizer_uri: nil, auth_type: nil, identity_source: nil, identity_validation_expression: nil, provider_arns: nil)
  @name = name
  Jsii::Type.check_type(@name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "name")
  @rest_api_id = rest_api_id
  Jsii::Type.check_type(@rest_api_id, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3sicHJpbWl0aXZlIjoic3RyaW5nIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19hcGlnYXRld2F5LklSZXN0QXBpUmVmIn1dfX0=")), "restApiId")
  @type = type
  Jsii::Type.check_type(@type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "type")
  @authorizer_credentials = authorizer_credentials
  Jsii::Type.check_type(@authorizer_credentials, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3sicHJpbWl0aXZlIjoic3RyaW5nIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19pYW0uSVJvbGVSZWYifV19fQ==")), "authorizerCredentials") unless @authorizer_credentials.nil?
  @authorizer_result_ttl_in_seconds = authorizer_result_ttl_in_seconds
  Jsii::Type.check_type(@authorizer_result_ttl_in_seconds, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "authorizerResultTtlInSeconds") unless @authorizer_result_ttl_in_seconds.nil?
  @authorizer_uri = authorizer_uri
  Jsii::Type.check_type(@authorizer_uri, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "authorizerUri") unless @authorizer_uri.nil?
  @auth_type = auth_type
  Jsii::Type.check_type(@auth_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "authType") unless @auth_type.nil?
  @identity_source = identity_source
  Jsii::Type.check_type(@identity_source, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "identitySource") unless @identity_source.nil?
  @identity_validation_expression = identity_validation_expression
  Jsii::Type.check_type(@identity_validation_expression, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "identityValidationExpression") unless @identity_validation_expression.nil?
  @provider_arns = provider_arns
  Jsii::Type.check_type(@provider_arns, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InVuaW9uIjp7InR5cGVzIjpbeyJwcmltaXRpdmUiOiJzdHJpbmcifSx7ImZxbiI6ImF3cy1jZGstbGliLmludGVyZmFjZXMuYXdzX2NvZ25pdG8uSVVzZXJQb29sUmVmIn1dfX0sImtpbmQiOiJhcnJheSJ9fQ==")), "providerArns") unless @provider_arns.nil?
end

Instance Attribute Details

#auth_typeString? (readonly)

Optional customer-defined field, used in OpenAPI imports and exports without functional impact.



84
85
86
# File 'api_gateway/cfn_authorizer_props.rb', line 84

def auth_type
  @auth_type
end

#authorizer_credentialsString, ... (readonly)

Specifies the required credentials as an IAM role for API Gateway to invoke the authorizer.

To specify an IAM role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To use resource-based permissions on the Lambda function, specify null.



65
66
67
# File 'api_gateway/cfn_authorizer_props.rb', line 65

def authorizer_credentials
  @authorizer_credentials
end

#authorizer_result_ttl_in_secondsNumeric? (readonly)

The TTL in seconds of cached authorizer results.

If it equals 0, authorization caching is disabled. If it is greater than 0, API Gateway will cache authorizer responses. If this field is not set, the default value is 300. The maximum value is 3600, or 1 hour.



72
73
74
# File 'api_gateway/cfn_authorizer_props.rb', line 72

def authorizer_result_ttl_in_seconds
  @authorizer_result_ttl_in_seconds
end

#authorizer_uriString? (readonly)

Specifies the authorizer's Uniform Resource Identifier (URI).

For TOKEN or REQUEST authorizers, this must be a well-formed Lambda function URI, for example, arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations . In general, the URI has this form arn:aws:apigateway:{region}:lambda:path/{service_api} , where {region} is the same as the region hosting the Lambda function, path indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial / . For Lambda functions, this is usually of the form /2015-03-31/functions/[FunctionARN]/invocations .



79
80
81
# File 'api_gateway/cfn_authorizer_props.rb', line 79

def authorizer_uri
  @authorizer_uri
end

#identity_sourceString? (readonly)

The identity source for which authorization is requested.

For a TOKEN or COGNITO_USER_POOLS authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name is Auth , the header mapping expression is method.request.header.Auth . For the REQUEST authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if an Auth header, a Name query string parameter are defined as identity sources, this value is method.request.header.Auth, method.request.querystring.Name . These parameters will be used to derive the authorization caching key and to perform runtime validation of the REQUEST authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional.



91
92
93
# File 'api_gateway/cfn_authorizer_props.rb', line 91

def identity_source
  @identity_source
end

#identity_validation_expressionString? (readonly)

A validation expression for the incoming identity token.

For TOKEN authorizers, this value is a regular expression. For COGNITO_USER_POOLS authorizers, API Gateway will match the aud field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to the REQUEST authorizer.



98
99
100
# File 'api_gateway/cfn_authorizer_props.rb', line 98

def identity_validation_expression
  @identity_validation_expression
end

#nameString (readonly)

The name of the authorizer.



46
47
48
# File 'api_gateway/cfn_authorizer_props.rb', line 46

def name
  @name
end

#provider_arnsArray<String, AWSCDK::Interfaces::AWSCognito::IUserPoolRef>? (readonly)

A list of the Amazon Cognito user pool ARNs for the COGNITO_USER_POOLS authorizer.

Each element is of this format: arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id} . For a TOKEN or REQUEST authorizer, this is not defined.



105
106
107
# File 'api_gateway/cfn_authorizer_props.rb', line 105

def provider_arns
  @provider_arns
end

#rest_api_idString, AWSCDK::Interfaces::AWSApigateway::IRestAPIRef (readonly)

The string identifier of the associated RestApi.



51
52
53
# File 'api_gateway/cfn_authorizer_props.rb', line 51

def rest_api_id
  @rest_api_id
end

#typeString (readonly)

The authorizer type.

Valid values are TOKEN for a Lambda function using a single authorization token submitted in a custom header, REQUEST for a Lambda function using incoming request parameters, and COGNITO_USER_POOLS for using an Amazon Cognito user pool.



58
59
60
# File 'api_gateway/cfn_authorizer_props.rb', line 58

def type
  @type
end

Class Method Details

.jsii_propertiesObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'api_gateway/cfn_authorizer_props.rb', line 107

def self.jsii_properties
  {
    :name => "name",
    :rest_api_id => "restApiId",
    :type => "type",
    :authorizer_credentials => "authorizerCredentials",
    :authorizer_result_ttl_in_seconds => "authorizerResultTtlInSeconds",
    :authorizer_uri => "authorizerUri",
    :auth_type => "authType",
    :identity_source => "identitySource",
    :identity_validation_expression => "identityValidationExpression",
    :provider_arns => "providerArns",
  }
end

Instance Method Details

#to_jsiiObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'api_gateway/cfn_authorizer_props.rb', line 122

def to_jsii
  result = {}
  result.merge!({
    "name" => @name,
    "restApiId" => @rest_api_id,
    "type" => @type,
    "authorizerCredentials" => @authorizer_credentials,
    "authorizerResultTtlInSeconds" => @authorizer_result_ttl_in_seconds,
    "authorizerUri" => @authorizer_uri,
    "authType" => @auth_type,
    "identitySource" => @identity_source,
    "identityValidationExpression" => @identity_validation_expression,
    "providerArns" => @provider_arns,
  })
  result.compact
end