You are here

function saml_sp__logout in SAML Service Provider 7.2

Same name and namespace in other branches
  1. 8.3 saml_sp.pages.inc \saml_sp__logout()
  2. 8.2 saml_sp.pages.inc \saml_sp__logout()
  3. 7.8 saml_sp.pages.inc \saml_sp__logout()
  4. 7.3 saml_sp.pages.inc \saml_sp__logout()
  5. 4.x saml_sp.pages.inc \saml_sp__logout()
  6. 3.x saml_sp.pages.inc \saml_sp__logout()

Page callback to initiate the SAML SLO process.

1 string reference to 'saml_sp__logout'
saml_sp_menu in ./saml_sp.module
Implements hook_menu().

File

./saml_sp.pages.inc, line 121
User pages for the SAML Service Provider module.

Code

function saml_sp__logout() {

  // Load the IDP to authenticate against.
  $idp = saml_sp_drupal_login__get_idp();

  // Settings is a OneLogin_Saml2_Settings object.
  $settings = saml_sp__get_settings($idp);
  $auth = new OneLogin_Saml2_Auth($settings);

  // Handle SAML Request / Response and process Single LogOut
  $auth
    ->processSLO();
  $errors = $auth
    ->getErrors();
  if (empty($errors)) {
    watchdog('saml_sp', 'Handled SLO Request/Response from SSO.');
  }
  else {
    watchdog('saml_sp', 'Errors in SLO process: %errors', array(
      '%errors' => implode(', ', $errors),
    ));
  }

  // Redirect user to path defined in RelayState after logout, or to front page
  // if it's empty
  drupal_set_message(t('You have successfully logged out from all SSO services.'));
  drupal_goto($_GET['RelayState']);
}