-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsimplesamlphp_auth.install
More file actions
102 lines (93 loc) · 4.81 KB
/
Copy pathsimplesamlphp_auth.install
File metadata and controls
102 lines (93 loc) · 4.81 KB
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
<?php
/**
* @file
* the install file for the simplesamlphp_auth module
*/
/**
* Implements hook_install().
*/
function simplesamlphp_auth_install() {
// Disable the open registration to the site and store the original setting.
$original = config_get('system.core', 'user_register');
config_set('system.core', 'user_register', 0);
config_set('simplesamlphp_auth.settings', 'user_register_original', $original);
}
/**
* Implements hook_requirements().
*/
function simplesamlphp_auth_requirements($phase) {
$config = config('simplesamlphp_auth.settings');
$requirements = array();
if ($phase == 'runtime') {
if (!$config->get('activate')) {
$requirements['simplesamlphp_auth'] = array(
'severity' => REQUIREMENT_INFO,
'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 = $config->get('installdir');
if (!class_exists('\SimpleSAML\Configuration') && !file_exists($basedir . '/lib/_autoload.php')) {
$requirements['simplesamlphp_auth'] = array(
'severity' => REQUIREMENT_WARNING,
'title' => 'simpleSAMLphp_auth',
'value' => t('Missing SimpleSAMLphp library'),
'description' => t('This module requires the SimpleSAMLphp library. See the !simplesamlphp module project page for further information.', array('!simplesamlphp' => l(t('SimpleSAMLphp'), 'https://backdropcms.org/project/simplesamlphp_auth'))),
);
}
}
return $requirements;
}
/**
* Migrate simplesamlphp_auth variables to config.
*/
function simplesamlphp_auth_update_1000() {
$config = config('simplesamlphp_auth.settings');
$config->set('activate', update_variable_get('simplesamlphp_auth_activate', ''));
$config->set('installdir', update_variable_get('simplesamlphp_auth_installdir', '/var/simplesamlphp'));
$config->set('authsource', update_variable_get('simplesamlphp_auth_authsource', 'default-sp'));
$config->set('forcehttps', update_variable_get('simplesamlphp_auth_forcehttps', TRUE));
$config->set('user_name', update_variable_get('simplesamlphp_auth_user_name', 'eduPersonPrincipalName'));
$config->set('unique_id', update_variable_get('simplesamlphp_auth_unique_id', 'eduPersonPrincipalName'));
$config->set('mailattr', update_variable_get('simplesamlphp_auth_mailattr', 'mail'));
$config->set('rolepopulation', update_variable_get('simplesamlphp_auth_rolepopulation', ''));
$config->set('roleevaleverytime', update_variable_get('simplesamlphp_auth_roleevaleverytime', '0'));
$config->set('registerusers', update_variable_get('simplesamlphp_auth_registerusers', TRUE));
$config->set('allowsetdrupalpwd', update_variable_get('simplesamlphp_auth_allowsetdrupalpwd', ''));
$config->set('allowdefaultlogin', update_variable_get('simplesamlphp_auth_allowdefaultlogin', TRUE));
$config->set('roles', update_variable_get('simplesamlphp_auth_roles', array()));
$config->set('users', update_variable_get('simplesamlphp_auth_users', ''));
$config->set('logoutgotourl', update_variable_get('simplesamlphp_auth_logoutgotourl', ''));
$config->set('user_register_original', update_variable_get('simplesamlphp_auth_user_register_original', '1'));
$config->set('login_link_display_name', update_variable_get('simplesamlphp_auth_link_display_name', 'Federated Login'));
$config->save();
update_variable_del('simplesamlphp_auth_activate');
update_variable_del('simplesamlphp_auth_installdir');
update_variable_del('simplesamlphp_auth_authsource');
update_variable_del('simplesamlphp_auth_forcehttps');
update_variable_del('simplesamlphp_auth_user_name');
update_variable_del('simplesamlphp_auth_unique_id');
update_variable_del('simplesamlphp_auth_mailattr');
update_variable_del('simplesamlphp_auth_rolepopulation');
update_variable_del('simplesamlphp_auth_roleevaleverytime');
update_variable_del('simplesamlphp_auth_registerusers');
update_variable_del('simplesamlphp_auth_allowsetdrupalpwd');
update_variable_del('simplesamlphp_auth_allowdefaultlogin');
update_variable_del('simplesamlphp_auth_roles');
update_variable_del('simplesamlphp_auth_users');
update_variable_del('simplesamlphp_auth_logoutgotourl');
update_variable_del('simplesamlphp_auth_user_register_original');
update_variable_del('simplesamlphp_auth_login_link_display_name');
}
/**
* Ensure a default value for the login link title and allow translation.
*/
function simplesamlphp_auth_update_1200() {
$config = config('simplesamlphp_auth.settings');
if (empty($config->get('login_link_display_name'))) {
$config->set('login_link_display_name', 'Federated Login');
}
$config->set('_config_translatables', array('login_link_display_name'));
$config->save();
}