-
Notifications
You must be signed in to change notification settings - Fork 0
/
onelogin.install
74 lines (63 loc) · 2.19 KB
/
onelogin.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
<?php
/**
* @file
* Install and update functions and hooks for the OneLogin module.
*/
/**
* Implements hook_requirements().
*/
function onelogin_requirements($phase) {
$requirements = array();
$t = get_t();
// Ensure that OneLogin PHP Library is installed.
$requirements['onelogin_library'] = array(
'title' => $t('OneLogin SAML library'),
'description' => $t('Make sure to install the OneLogin PHP SAML library (v1.0.0 or greater) at sites/*/libraries/onelogin.'),
'severity' => REQUIREMENT_WARNING,
);
// Ensure that OneLogin is properly configured.
$requirements['onelogin_config'] = array(
'title' => $t('OneLogin configuration'),
'description' => $t('Make sure to provide a valid x.509 certificate and SAML login URL.'),
'severity' => REQUIREMENT_WARNING,
);
// Things to check during runtime.
if ($phase == 'runtime') {
// Ensure that the library is available and loaded.
if (($library = libraries_detect('onelogin')) && !empty($library['installed'])) {
$requirements['onelogin_library']['value'] = $t('Installed');
$requirements['onelogin_library']['severity'] = REQUIREMENT_OK;
$requirements['onelogin_library']['description'] = '';
}
else {
$requirements['onelogin_library']['value'] = l($t('Missing'), 'https://github.com/onelogin/php-saml/releases');
}
// Ensure that required fields are filled out.
$cert = variable_get('onelogin_cert', FALSE);
$login_url = variable_get('onelogin_login_url', FALSE);
if (empty($cert) || empty($login_url)) {
$requirements['onelogin_config']['value'] = l($t('Needs configuration'), 'admin/config/people/onelogin');
}
else {
$requirements['onelogin_config']['value'] = $t('Configured');
$requirements['onelogin_config']['severity'] = REQUIREMENT_OK;
$requirements['onelogin_config']['description'] = '';
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function onelogin_uninstall() {
$vars = array(
'onelogin_cert',
'onelogin_login_url',
'onelogin_autoprovision',
'onelogin_autoprovision_email_pregmatch',
'onelogin_required_globally',
);
foreach ($vars as $var) {
variable_del($var);
}
}