Class: Maestrano::Rails::SamlBaseController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/maestrano/rails/saml_base_controller.rb

Direct Known Subclasses

Auth::SamlController

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#group_auth_hashObject (readonly)

Returns the value of attribute group_auth_hash.



2
3
4
# File 'app/controllers/maestrano/rails/saml_base_controller.rb', line 2

def group_auth_hash
  @group_auth_hash
end

#saml_responseObject (readonly)

Returns the value of attribute saml_response.



2
3
4
# File 'app/controllers/maestrano/rails/saml_base_controller.rb', line 2

def saml_response
  @saml_response
end

#user_auth_hashObject (readonly)

Returns the value of attribute user_auth_hash.



2
3
4
# File 'app/controllers/maestrano/rails/saml_base_controller.rb', line 2

def user_auth_hash
  @user_auth_hash
end

#user_group_rel_hashObject (readonly)

Returns the value of attribute user_group_rel_hash.



2
3
4
# File 'app/controllers/maestrano/rails/saml_base_controller.rb', line 2

def user_group_rel_hash
  @user_group_rel_hash
end

Instance Method Details

#initObject

GET /maestrano/auth/saml/init/:tenant

Initialize the SAML request and redirects the user to Maestrano



9
10
11
# File 'app/controllers/maestrano/rails/saml_base_controller.rb', line 9

def init
  redirect_to Maestrano::Saml::Request[params[:tenant]].new(params, session).redirect_url
end

#process_saml_responseObject



32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/maestrano/rails/saml_base_controller.rb', line 32

def process_saml_response
  if params[:SAMLResponse]
    @saml_response = Maestrano::Saml::Response[params[:tenant]].new(params[:SAMLResponse])
    if @saml_response.validate!
      @user_auth_hash = Maestrano::SSO::BaseUser[params[:tenant]].new(@saml_response).to_hash
      @group_auth_hash = Maestrano::SSO::BaseGroup.new(@saml_response).to_hash
      @user_group_rel_hash = Maestrano::SSO::BaseMembership.new(@saml_response).to_hash
    end
  end
end

#saml_response_transactionObject

Helper methods



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/maestrano/rails/saml_base_controller.rb', line 16

def saml_response_transaction
  begin
    process_saml_response
    yield
    Maestrano::SSO.set_session(session,@user_auth_hash)
  rescue Exception => e
    if Rails.env.development?
      raise
    else
      logger.error "Cannot validate SAML response: #{e.message}"
      logger.debug "Trace: #{e.backtrace}"
      redirect_to "#{Maestrano::SSO.unauthorized_url}?err=internal"
    end
  end
end