Class: OmniAuth::Strategies::SSO

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/sso/client/omniauth/strategies/sso.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.development_environment?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/sso/client/omniauth/strategies/sso.rb', line 19

def self.development_environment?
  defined?(Rails) && Rails.env.development?
end

.endpointObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sso/client/omniauth/strategies/sso.rb', line 7

def self.endpoint
  if ENV['OMNIAUTH_SSO_ENDPOINT'].to_s != ''
    ENV['OMNIAUTH_SSO_ENDPOINT'].to_s
  elsif development_environment?
    ENV['OMNIAUTH_SSO_ENDPOINT'] || 'http://sso.dev:8080'
  elsif test_environment?
    'https://sso.example.com'
  else
    fail 'You must set OMNIAUTH_SSO_ENDPOINT to point to the SSO OAuth server'
  end
end

.passports_pathObject



27
28
29
30
31
32
33
34
# File 'lib/sso/client/omniauth/strategies/sso.rb', line 27

def self.passports_path
  if ENV['OMNIAUTH_SSO_PASSPORTS_PATH'].to_s != ''
    ENV['OMNIAUTH_SSO_PASSPORTS_PATH'].to_s
  else
    # We know this namespace is not occupied because /oauth is owned by Doorkeeper
    '/oauth/sso/v1/passports'
  end
end

.test_environment?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/sso/client/omniauth/strategies/sso.rb', line 23

def self.test_environment?
  defined?(Rails) && Rails.env.test? || ENV['RACK_ENV'] == 'test'
end

Instance Method Details

#raw_infoObject



51
52
53
54
# File 'lib/sso/client/omniauth/strategies/sso.rb', line 51

def raw_info
  params = { ip: request.ip, agent: request.user_agent }
  @raw_info ||= access_token.post(self.class.passports_path, params: params).parsed
end