Class: FmRest::Cloud::ClarisIdTokenManager

Inherits:
Object
  • Object
show all
Includes:
TokenStore
Defined in:
lib/fmrest/cloud/claris_id_token_manager.rb

Constant Summary collapse

COGNITO_CLIENT_ID =
"4l9rvl4mv5es1eep1qe97cautn"
COGNITO_POOL_ID =
"us-west-2_NqkuZcXQY"
AWS_REGION =
"us-west-2"
TOKEN_STORE_PREFIX =
"claris-cognito"

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ ClarisIdTokenManager

Returns a new instance of ClarisIdTokenManager.



16
17
18
# File 'lib/fmrest/cloud/claris_id_token_manager.rb', line 16

def initialize(settings)
  @settings = settings
end

Instance Method Details

#expire_tokenObject



33
34
35
# File 'lib/fmrest/cloud/claris_id_token_manager.rb', line 33

def expire_token
  token_store.delete(token_store_key)
end

#fetch_tokenObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fmrest/cloud/claris_id_token_manager.rb', line 20

def fetch_token
  if token = token_store.load(token_store_key)
    return token
  end

  tokens = get_cognito_tokens

  token_store.store(token_store_key, tokens.id_token)
  token_store.store(token_store_key(:refresh), tokens.refresh_token) if tokens.refresh_token

  tokens.id_token
end