function cas_phpcas_init in CAS 6.3
Same name and namespace in other branches
- 7 cas.module \cas_phpcas_init()
Initialize phpCAS.
Will load phpCAS if necessary.
Parameters
$force: phpCAS cannot be initialized twice. If you need to force this function to run again, set this to TRUE.
3 calls to cas_phpcas_init()
- cas_login_check in ./
cas.module - Checks to see if the user needs to be logged in.
- cas_logout in ./
cas.module - Logs a user out of Drupal and then out of CAS.
- cas_phpcas_attributes in ./
cas.module - Get the CAS attributes of the current CAS user.
File
- ./
cas.module, line 243 - Enables users to authenticate via a Central Authentication Service (CAS) Cas will currently work if the auto registration is turned on and will create user accounts automatically.
Code
function cas_phpcas_init($force = FALSE) {
if (!defined('PHPCAS_VERSION') || !class_exists('phpCAS')) {
cas_phpcas_load();
}
static $initialized = FALSE;
if ($initialized && !$force) {
return;
}
$initialized = TRUE;
// Variable set
$server_version = (string) variable_get('cas_version', '2.0');
$server_cas_server = (string) variable_get('cas_server', 'sso-cas.univ-rennes1.fr');
$server_port = (int) variable_get('cas_port', '443');
$server_uri = (string) variable_get('cas_uri', '');
$cas_cert = (string) variable_get('cas_cert', '');
$debug_file = (string) variable_get('cas_debugfile', '');
if ($debug_file != '') {
phpCAS::setDebug($debug_file);
}
$start_session = (bool) FALSE;
if (variable_get('cas_proxy', 0)) {
phpCAS::proxy($server_version, $server_cas_server, $server_port, $server_uri, $start_session);
$cas_pgt_storage_path = variable_get('cas_pgtpath', '');
if ($cas_pgt_storage_path != '') {
if (version_compare(PHPCAS_VERSION, '1.3', '>=')) {
phpCAS::setPGTStorageFile($cas_pgt_storage_path);
}
else {
$cas_pgt_format = variable_get('cas_pgtformat', 'plain');
phpCAS::setPGTStorageFile($cas_pgt_format, $cas_pgt_storage_path);
}
}
}
else {
phpCAS::client($server_version, $server_cas_server, $server_port, $server_uri, $start_session);
}
// force CAS authentication
if ($cas_cert = variable_get('cas_cert', '')) {
phpCAS::setCasServerCACert($cas_cert);
}
else {
phpCAS::setNoCasServerValidation();
}
$service = isset($_GET['q']) ? $_GET['q'] : 'cas';
phpCAS::setFixedServiceURL(url($service, array(
'query' => cas_login_destination(),
'absolute' => TRUE,
)));
// Allow other modules to call phpCAS routines. We do not call
// drupal_alter() since there are no parameters to pass.
module_invoke_all('cas_phpcas_alter');
}