Class: CognitoTokenVerifier::Config
- Inherits:
-
Object
- Object
- CognitoTokenVerifier::Config
- Defined in:
- lib/cognito_token_verifier/config.rb
Instance Attribute Summary collapse
-
#allow_expired_tokens ⇒ Object
Returns the value of attribute allow_expired_tokens.
-
#aws_region ⇒ Object
Returns the value of attribute aws_region.
-
#token_use ⇒ Object
Returns the value of attribute token_use.
-
#user_pool_id ⇒ Object
Returns the value of attribute user_pool_id.
Instance Method Summary collapse
- #allow_expired_tokens? ⇒ Boolean
- #any_token_use? ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #iss ⇒ Object
- #jwks ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 12 |
# File 'lib/cognito_token_verifier/config.rb', line 7 def initialize @aws_region = nil @user_pool_id = nil @token_use = 'all' @allow_expired_tokens = false end |
Instance Attribute Details
#allow_expired_tokens ⇒ Object
Returns the value of attribute allow_expired_tokens.
5 6 7 |
# File 'lib/cognito_token_verifier/config.rb', line 5 def allow_expired_tokens @allow_expired_tokens end |
#aws_region ⇒ Object
Returns the value of attribute aws_region.
5 6 7 |
# File 'lib/cognito_token_verifier/config.rb', line 5 def aws_region @aws_region end |
#token_use ⇒ Object
Returns the value of attribute token_use.
5 6 7 |
# File 'lib/cognito_token_verifier/config.rb', line 5 def token_use @token_use end |
#user_pool_id ⇒ Object
Returns the value of attribute user_pool_id.
5 6 7 |
# File 'lib/cognito_token_verifier/config.rb', line 5 def user_pool_id @user_pool_id end |
Instance Method Details
#allow_expired_tokens? ⇒ Boolean
18 19 20 |
# File 'lib/cognito_token_verifier/config.rb', line 18 def allow_expired_tokens? allow_expired_tokens end |
#any_token_use? ⇒ Boolean
14 15 16 |
# File 'lib/cognito_token_verifier/config.rb', line 14 def any_token_use? ['all', 'any', ['id', 'access']].any?{|usage| usage == token_use } end |
#iss ⇒ Object
31 32 33 |
# File 'lib/cognito_token_verifier/config.rb', line 31 def iss "https://cognito-idp.#{aws_region}.amazonaws.com/#{user_pool_id}" end |
#jwks ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/cognito_token_verifier/config.rb', line 22 def jwks begin raise ConfigSetupError.new(self) unless aws_region.present? and user_pool_id.present? @jwks ||= JSON.parse(RestClient.get(jwk_url)) rescue RestClient::Exception, JSON::JSONError => e raise JWKFetchError end end |