Class: CognitoTokenVerifier::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cognito_token_verifier/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

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_tokensObject

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_regionObject

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_useObject

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_idObject

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

Returns:

  • (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

Returns:

  • (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

#issObject



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

#jwksObject



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