Class: Devise::SamlSessionsController

Inherits:
SessionsController
  • Object
show all
Includes:
DeviseSamlAuthenticatable::SamlConfig
Defined in:
app/controllers/devise/saml_sessions_controller.rb

Instance Method Summary collapse

Methods included from DeviseSamlAuthenticatable::SamlConfig

#saml_config

Instance Method Details

#idp_sign_outObject


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/devise/saml_sessions_controller.rb', line 28

def idp_sign_out
  if params[:SAMLRequest] && Devise.saml_session_index_key
    saml_config = saml_config(get_idp_entity_id(params))
    logout_request = OneLogin::RubySaml::SloLogoutrequest.new(params[:SAMLRequest], settings: saml_config)
    resource_class.reset_session_key_for(logout_request.name_id)

    redirect_to generate_idp_logout_response(saml_config, logout_request.id)
  elsif params[:SAMLResponse]
    # Currently Devise handles the session invalidation when the request is made.
    # To support a true SP initiated logout response, the request ID would have to be tracked and session invalidated
    # based on that.
    if Devise.saml_sign_out_success_url
      redirect_to Devise.saml_sign_out_success_url
    else
      redirect_to action: :new
    end
  else
    head 500
  end
end

#metadataObject


22
23
24
25
26
# File 'app/controllers/devise/saml_sessions_controller.rb', line 22

def 
  idp_entity_id = params[:idp_entity_id]
  meta = OneLogin::RubySaml::Metadata.new
  render :xml => meta.generate(saml_config(idp_entity_id))
end

#newObject


14
15
16
17
18
19
20
# File 'app/controllers/devise/saml_sessions_controller.rb', line 14

def new
  idp_entity_id = get_idp_entity_id(params)
  request = OneLogin::RubySaml::Authrequest.new
  auth_params = { RelayState: relay_state } if relay_state
  action = request.create(saml_config(idp_entity_id), auth_params || {})
  redirect_to action
end