You are here

function _simplesamlphp_auth_isEnabled in simpleSAMLphp Authentication 7

Same name and namespace in other branches
  1. 6.3 simplesamlphp_auth.module \_simplesamlphp_auth_isEnabled()
  2. 6.2 simplesamlphp_auth.module \_simplesamlphp_auth_isEnabled()
  3. 7.3 simplesamlphp_auth.module \_simplesamlphp_auth_isEnabled()
  4. 7.2 simplesamlphp_auth.module \_simplesamlphp_auth_isEnabled()

Checks to see if authentication via SimpleSAMLphp should be activated

Return value

TRUE/FALSE

2 calls to _simplesamlphp_auth_isEnabled()
simplesamlphp_auth_init in ./simplesamlphp_auth.module
Implements hook_init().
simplesamlphp_auth_loginpage in ./simplesamlphp_auth.module
Represents the Drupal page (saml_login), which triggers user authentication against the SimpleSAMLphp service provider.

File

./simplesamlphp_auth.module, line 516
simpleSAMLphp authentication module for Drupal.

Code

function _simplesamlphp_auth_isEnabled() {
  global $user;
  $failure = NULL;
  $isActivated = variable_get('simplesamlphp_auth_activate');
  $basedir = variable_get('simplesamlphp_auth_installdir', '/var/simplesamlphp');
  if (!$isActivated) {
    $adminPath = array_keys(simplesamlphp_auth_admin_paths());
    $failure = t('SimpleSAMLphp authentication is NOT yet activated. It can be activated on the ' . l('configuration page', $adminPath[0]) . '.');
    watchdog('simplesamlphp_auth', $failure, NULL, WATCHDOG_WARNING);
    if ($user->uid != 0) {
      drupal_set_message($failure);
    }
  }
  else {

    // Make sure we know where SimpleSAMLphp is.
    if (!file_exists($basedir)) {
      $failure = t('SimpleSAMLphp could not be found at %basedir . The simplesamlphp_auth module cannot function until the path to the local SimpleSAMLphp instance is configured.', array(
        '%basedir' => $basedir,
      ));
      watchdog('simplesamlphp_auth', $failure, NULL, WATCHDOG_WARNING);
      if ($user->uid != 0) {
        drupal_set_message($failure);
      }
    }
  }

  // If there were no failures, then it should be activated
  if (!$failure) {
    return TRUE;
  }
  return FALSE;
}