Class: Maestrano::Auth::SamlController

Inherits:
Rails::SamlBaseController
  • Object
show all
Defined in:
app/controllers/maestrano/auth/saml_controller.rb

Instance Method Summary collapse

Instance Method Details

#consumeObject

POST ‘/maestrano/auth/saml/consume’

Final phase of the Single Sign-On handshake. Find or create the required resources (user and group) and sign the user in



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/maestrano/auth/saml_controller.rb', line 11

def consume
  params[:tenant] ||= 'default'
  user = Maestrano::Connector::Rails::User.find_or_create_for_maestrano(user_auth_hash, params[:tenant])
  organization = Maestrano::Connector::Rails::Organization.find_or_create_for_maestrano(group_auth_hash, params[:tenant])

  Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "user authentication, user_uid=\"#{user.uid}\"")

  if user && organization
    organization.add_member(user) unless organization.member?(user)

    session[:tenant] = params[:tenant]
    session[:uid] = user.uid
    session[:org_uid] = organization.uid
    session[:"role_#{organization.uid}"] = user_group_rel_hash[:role]
  end

  if session[:settings]
    session.delete(:settings)
    redirect_to main_app.root_path
  elsif current_organization&.oauth_uid && current_organization&.sync_enabled
    redirect_to main_app.home_redirect_to_external_path
  else
    redirect_to main_app.root_path
  end
end

#initObject



2
3
4
5
# File 'app/controllers/maestrano/auth/saml_controller.rb', line 2

def init
  session[:settings] = !!params[:settings]
  super
end