Class: SignIn::AccessTokenAudienceGenerator

Inherits:
Object
  • Object
show all
Defined in:
app/services/sign_in/access_token_audience_generator.rb

Constant Summary collapse

SHARED_SESSION_CLIENT_IDS_CACHE_KEY =
'sis_shared_sessions_client_ids'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_config:) ⇒ AccessTokenAudienceGenerator

Returns a new instance of AccessTokenAudienceGenerator.



7
8
9
# File 'app/services/sign_in/access_token_audience_generator.rb', line 7

def initialize(client_config:)
  @client_config = client_config
end

Instance Attribute Details

#client_configObject (readonly, private)

Returns the value of attribute client_config.



17
18
19
# File 'app/services/sign_in/access_token_audience_generator.rb', line 17

def client_config
  @client_config
end

Instance Method Details

#generate_audienceObject (private)



19
20
21
22
23
# File 'app/services/sign_in/access_token_audience_generator.rb', line 19

def generate_audience
  return shared_session_client_ids if client_config.shared_sessions?

  [client_config.client_id]
end

#performObject



11
12
13
# File 'app/services/sign_in/access_token_audience_generator.rb', line 11

def perform
  generate_audience
end

#shared_session_client_idsObject (private)



25
26
27
28
29
# File 'app/services/sign_in/access_token_audience_generator.rb', line 25

def shared_session_client_ids
  @shared_session_client_ids ||= Rails.cache.fetch(SHARED_SESSION_CLIENT_IDS_CACHE_KEY, expires_in: 5.minutes) do
    ClientConfig.where(shared_sessions: true).pluck(:client_id)
  end
end