You are here

function shib_auth_user in Shibboleth Authentication 6.3

Same name and namespace in other branches
  1. 5.3 shib_auth.module \shib_auth_user()
  2. 5.2 shib_auth.module \shib_auth_user()
  3. 6.4 shib_auth.module \shib_auth_user()
  4. 6 shib_auth.module \shib_auth_user()
  5. 6.2 shib_auth.module \shib_auth_user()

Let the user exit from the Shibboleth authority when he/she log out from the actual Drupal site.

Parameters

op What kind of action is being performed.:

edit The array of form values submitted by the user.:

account The user object on which the operation is being performed.:

category The active category of user information being edited.:

File

./shib_auth.module, line 235
This is a Shibboleth authentication module.

Code

function shib_auth_user($op, &$edit, &$account, $category = NULL) {
  global $base_url, $user;
  if ($op == "logout") {
    $handlerurl = variable_get('shib_auth_handler_url', '/Shibboleth.sso');
    $handlerprotocol = variable_get('shib_auth_handler_protocol', 'https');
    if (ereg("^http[s]{0,1}://", $handlerurl)) {

      // If handlerurl is an absolute path
      $logouthandler = $handlerurl . "/Logout";
    }
    else {

      // Else, if the handlerurl is a relative path
      // If the WAYF's URI doesn't start with slash then extend it
      if (!ereg("^/", $handlerurl)) {
        $handlerurl = "/" . $handlerurl;
      }
      $logouthandler = $handlerprotocol . "://" . $_SERVER['HTTP_HOST'] . $handlerurl . "/Logout";
    }
    unset($_SESSION['authentication']);
    $logout_redirect = variable_get('shib_logout_url', $base_url);

    // If the logout_redirect URL was relative extension is needed.
    if (!ereg("^http[s]{0,1}://", $logout_redirect)) {
      $logout_redirect = $base_url . '/' . $logout_redirect;
    }
    drupal_goto("{$logouthandler}?return={$logout_redirect}");
  }
  elseif ($op == "delete") {
    db_query("DELETE FROM {authmap} WHERE uid = %d AND authname = '%s' AND module = 'shib_auth'", $account->uid, $account->name);
  }
}