Module: Maestrano::SSO

Includes:
Preset
Defined in:
lib/maestrano/sso.rb,
lib/maestrano/sso/user.rb,
lib/maestrano/sso/group.rb,
lib/maestrano/sso/session.rb,
lib/maestrano/sso/base_user.rb,
lib/maestrano/sso/base_group.rb,
lib/maestrano/sso/base_membership.rb

Defined Under Namespace

Modules: Group, User Classes: BaseGroup, BaseMembership, BaseUser, Session

Class Method Summary collapse

Methods included from Preset

included

Class Method Details

.build_request(get_params = {}) ⇒ Object

Build a new SAML Request



19
20
21
# File 'lib/maestrano/sso.rb', line 19

def self.build_request(get_params = {})
  Maestrano::Saml::Request[preset].new(get_params)
end

.build_response(saml_post_param) ⇒ Object

Build a new SAML response



24
25
26
# File 'lib/maestrano/sso.rb', line 24

def self.build_response(saml_post_param)
  Maestrano::Saml::Response[preset].new(saml_post_param)
end

.clear_session(session) ⇒ Object Also known as: unset_session

Destroy the maestrano session in http session



79
80
81
82
# File 'lib/maestrano/sso.rb', line 79

def self.clear_session(session)
  session.delete(:maestrano)
  session.delete('maestrano')
end

.consume_urlObject



38
39
40
41
42
# File 'lib/maestrano/sso.rb', line 38

def self.consume_url
  host = Maestrano[preset].param('sso.idm')
  path = Maestrano[preset].param('sso.consume_path')
  return "#{host}#{path}"
end

.enabled?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/maestrano/sso.rb', line 28

def self.enabled?
  !!Maestrano[preset].param('sso.enabled')
end

.idp_urlObject



57
58
59
60
61
62
# File 'lib/maestrano/sso.rb', line 57

def self.idp_url
  host = Maestrano[preset].param('api.host')
  api_base = Maestrano[preset].param('api.base')
  endpoint = 'auth/saml'
  return "#{host}#{api_base}#{endpoint}"
end

.init_urlObject



32
33
34
35
36
# File 'lib/maestrano/sso.rb', line 32

def self.init_url
  host = Maestrano[preset].param('sso.idm')
  path = Maestrano[preset].param('sso.init_path')
  return "#{host}#{path}"
end

.logout_url(user_uid = nil) ⇒ Object



44
45
46
47
48
49
# File 'lib/maestrano/sso.rb', line 44

def self.logout_url(user_uid = nil)
  host = Maestrano[preset].param('api.host')
  path = '/app_logout'
  path = "#{path}?user_uid=#{user_uid}" if user_uid
  return "#{host}#{path}"
end

.saml_settingsObject

Return the saml_settings based on Maestrano configuration



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

def self.saml_settings
  settings = Maestrano::Saml::Settings.new
  settings.assertion_consumer_service_url = self.consume_url
  settings.issuer                         = Maestrano[preset].param('api.id')
  settings.idp_sso_target_url             = self.idp_url
  settings.idp_cert                       = Maestrano[preset].param('sso.x509_certificate')
  settings.idp_cert_fingerprint           = Maestrano[preset].param('sso.x509_fingerprint')
  settings.name_identifier_format         = Maestrano[preset].param('sso.name_id_format')
  settings
end

.session_check_url(user_uid, sso_session) ⇒ Object



64
65
66
67
68
69
# File 'lib/maestrano/sso.rb', line 64

def self.session_check_url(user_uid, sso_session)
  host = Maestrano[preset].param('api.host')
  api_base = Maestrano[preset].param('api.base')
  endpoint = 'auth/saml'
  return URI.escape("#{host}#{api_base}#{endpoint}/#{user_uid}?session=#{sso_session}")
end

.set_session(session, auth) ⇒ Object

Set maestrano attributes in session Takes the BaseUser hash representation and current session in arguments



74
75
76
# File 'lib/maestrano/sso.rb', line 74

def self.set_session(session, auth)
  Maestrano::SSO::Session[preset].from_user_auth_hash(session,auth).save
end

.unauthorized_urlObject



51
52
53
54
55
# File 'lib/maestrano/sso.rb', line 51

def self.unauthorized_url
  host = Maestrano[preset].param('api.host')
  path = '/app_access_unauthorized'
  return "#{host}#{path}";
end