Class: StandardId::Oauth::TokenLifetimeResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/standard_id/oauth/token_lifetime_resolver.rb

Constant Summary collapse

DEFAULT_ACCESS_TOKEN_LIFETIME =
1.hour.to_i
DEFAULT_REFRESH_TOKEN_LIFETIME =
30.days.to_i
MAX_ACCESS_TOKEN_LIFETIME =
24.hours.to_i
MAX_REFRESH_TOKEN_LIFETIME =
90.days.to_i

Class Method Summary collapse

Class Method Details

.access_token_for(flow_key) ⇒ Object



10
11
12
13
14
# File 'lib/standard_id/oauth/token_lifetime_resolver.rb', line 10

def access_token_for(flow_key)
  configured = lookup_token_lifetime(flow_key)
  lifetime = positive_seconds(configured, default_access_token_lifetime)
  clamp_seconds(lifetime, MAX_ACCESS_TOKEN_LIFETIME)
end

.refresh_token_lifetimeObject



16
17
18
19
# File 'lib/standard_id/oauth/token_lifetime_resolver.rb', line 16

def refresh_token_lifetime
  lifetime = positive_seconds(oauth_config.refresh_token_lifetime, DEFAULT_REFRESH_TOKEN_LIFETIME)
  clamp_seconds(lifetime, MAX_REFRESH_TOKEN_LIFETIME)
end