-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimplesamlphp_auth.install
104 lines (92 loc) · 4.28 KB
/
simplesamlphp_auth.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* @file
* The install file for the simplesamlphp_auth module.
*/
/**
* Implements hook_install().
*/
function simplesamlphp_auth_install() {
user_role_revoke_permissions(DRUPAL_AUTHENTICATED_RID, array('change own password'));
// Disable the open registration to the site and store the original setting.
$original = variable_get('user_register', 1);
variable_set('user_register', 0);
variable_set('simplesamlphp_auth_user_register_original', $original);
// Inform the user about disabling the open registration.
drupal_set_message(t('The SimpleSAMLphp Authentication module disabled the user registration. You can manually enable it again in the <a href="@user_settings_url">Account settings</a>.', array('@user_settings_url' => url('admin/config/people/accounts'))), 'warning');
}
/**
* Implements hook_uninstall().
*/
function simplesamlphp_auth_uninstall() {
// Restore the original user registration directive.
$original = variable_get('simplesamlphp_auth_user_register_original', 1);
variable_set('user_register', $original);
variable_del('simplesamlphp_auth_user_register_original');
// Remove the created system variables.
variable_del('simplesamlphp_auth_activate');
variable_del('simplesamlphp_auth_installdir');
variable_del('simplesamlphp_auth_logout_page');
variable_del('simplesamlphp_auth_mailattr');
variable_del('simplesamlphp_auth_unique_id');
variable_del('simplesamlphp_auth_user_name');
variable_del('simplesamlphp_auth_authsource');
variable_del('simplesamlphp_auth_rolepopulation');
variable_del('simplesamlphp_auth_roleevaleverytime');
variable_del('simplesamlphp_auth_debug');
variable_del('simplesamlphp_auth_registerusers');
variable_del('simplesamlphp_auth_allowsetdrupalpwd');
variable_del('simplesamlphp_auth_allowdefaultlogin');
variable_del('simplesamlphp_auth_allowdefaultloginroles');
variable_del('simplesamlphp_auth_allowdefaultloginusers');
variable_del('simplesamlphp_auth_login_link_display_name');
variable_del('simplesamlphp_auth_logoutgotourl');
variable_del('simplesamlphp_auth_autoenablesaml');
}
/**
* Implements hook_requirements().
*/
function simplesamlphp_auth_requirements($phase) {
$t = get_t();
$requirements = array();
if ($phase == 'runtime') {
if (!variable_get('simplesamlphp_auth_activate', 0)) {
$requirements['simplesamlphp_auth'] = array(
'severity' => REQUIREMENT_WARNING,
'title' => 'SimpleSAMLphp auth',
'value' => $t('SimpleSAMLphp authentication is NOT activated'),
'description' => $t('It can be activated on the !admin_page.', array('!admin_page' => l($t('configuration page'), 'admin/config/people/simplesamlphp_auth'))),
);
}
$basedir = variable_get('simplesamlphp_auth_installdir', '/usr/share/simplesamlphp');
if (!file_exists($basedir . '/lib/_autoload.php')) {
$requirements['simplesamlphp_auth'] = array(
'severity' => REQUIREMENT_ERROR,
'title' => 'SimpleSAMLphp authentication',
'value' => $t('SimpleSAMLphp authentication is missing the required SimpleSAMLphp library.'),
'description' => $t('Please download and install the !simplesamlphp library.', array('!simplesamlphp' => l($t('SimpleSAMLphp'), 'https://simplesamlphp.org/download'))),
);
}
// SimpleSAMLphp is installed, lets autoload it
else if (_simplesaml_auth_autoload()) {
// If autoloading was successful we should have these variables.
global $_simplesamlphp_auth_saml_config;
global $_simplesamlphp_auth_saml_version;
if (!empty($_simplesamlphp_auth_saml_version)) {
$ver = explode('.', $_simplesamlphp_auth_saml_version);
$requirements['simplesamlphp_auth_version'] = array(
'title' => $t('SimpleSAMLphp authentication'),
'value' => $_simplesamlphp_auth_saml_version,
);
if ($ver[0] < 1 || ($ver[0] == 1 && $ver[1] < 6)) {
$requirements['simplesamlphp_auth_version']['description'] = $t('Your version of SimpleSAMLphp is too old. The minimum version is 1.6.');
$requirements['simplesamlphp_auth_version']['severity'] = REQUIREMENT_ERROR;
}
else {
$requirements['simplesamlphp_auth_version']['severity'] = REQUIREMENT_OK;
}
}
}
}
return $requirements;
}