You are here

ldap_sso.module in LDAP Single Sign On 8

This module injects itself into Drupal's Authentication stack.

File

ldap_sso.module
View source
<?php

/**
 * @file
 * This module injects itself into Drupal's Authentication stack.
 */
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RedirectResponse;

/**
 * Implements hook_user_logout().
 */
function ldap_sso_user_logout($account) {
  if (\Drupal::config('ldap_sso.settings')
    ->get('seamlessLogin') == 1) {
    if (\Drupal::config('ldap_sso.settings')
      ->get('cookieExpire')) {
      setcookie('sso_stop', 'true', REQUEST_TIME - 3600, base_path(), '');
    }
    else {
      setcookie('sso_stop', 'true', 0, base_path(), '');
    }
  }
  if (\Drupal::config('ldap_sso.settings')
    ->get('redirectOnLogout')) {
    $redirect_url = \Drupal::config('ldap_sso.settings')
      ->get('logoutRedirectPath');
    $redirect = new RedirectResponse(Url::fromUserInput($redirect_url)
      ->toString());
    $redirect
      ->send();
  }
}

/**
 * Implements hook_help().
 */
function ldap_sso_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.ldap_sso':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The LDAP SSO module provides integration for environments which provide an authenticated user through server headers.') . '</p>';
      return $output;
  }
}

Functions

Namesort descending Description
ldap_sso_help Implements hook_help().
ldap_sso_user_logout Implements hook_user_logout().