You are here

function samlauth_logout in SAML Authentication 7

Menu callback for /saml/logout.

1 string reference to 'samlauth_logout'
samlauth_menu in ./samlauth.module
Implements hook_menu().

File

./samlauth.module, line 244
Provides SAML authentication capabilities.

Code

function samlauth_logout() {
  $nameId = isset($_SESSION['samlauth']['nameId']) ? $_SESSION['samlauth']['nameId'] : NULL;
  $nameIdFormat = isset($_SESSION['samlauth']['nameIdFormat']) ? $_SESSION['samlauth']['nameIdFormat'] : NULL;
  $nameIdNameQualifier = isset($_SESSION['samlauth']['nameIdNameQualifier']) ? $_SESSION['samlauth']['nameIdNameQualifier'] : NULL;
  $sessionIndex = isset($_SESSION['samlauth']['sessionIndex']) ? $_SESSION['samlauth']['sessionIndex'] : NULL;
  if (user_is_logged_in()) {
    module_load_include('pages.inc', 'user');
    user_logout_current_user();
  }

  // Check if there is a SAML response already. We have no way of verifying the
  // response because SAML PHP processResponse() does not support logout
  // responses and processSlo() only looks at GET parameters.
  if (isset($_POST['SAMLResponse'])) {

    // Just assume everything went well and go to the frontpage.
    drupal_goto();
  }
  else {

    // Redirect to the auth server for logout.
    $auth = samlauth_get_saml2_auth();
    $auth
      ->logout('/', array(), $nameId, $sessionIndex, FALSE, $nameIdFormat, $nameIdNameQualifier);
  }
}