-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsimplesamlphp_auth.install
128 lines (117 loc) · 4.17 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* @file
* the install file for the simplesamlphp_auth module
* This module belongs to Andreas Åkre Solberg, Snorre Løvås and Steve Moitozo (Maintenance)
* the adjustments we're doing is to allow multiple IDPs and SPs on the same website with custom
* logic from TA
* @version 7.x.3.5
* @author Pablo Tapia <pablo.orozco@ingenia.com>
* @author Angel Alvarado <angel.angelio.ingenia@gmail.com>
*/
/**
* Implements hook_schema().
*/
function simplesamlphp_auth_schema() {
$schema = array();
$schema['saml_idp_settings'] = array(
'description' => 'The table for SAML IDP configurations ',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key.',
),
'source_name' => array(
'type' => 'varchar',
'length' => 150,
'not null' => TRUE,
'description' => 'Source name for this connection',
),
'company' => array(
'type' => 'varchar',
'length' => 150,
'not null' => TRUE,
'description' => 'Name of the company that\'s the owner of the IDP',
),
'domain' => array(
'type' => 'varchar',
'length' => 200,
'not null' => TRUE,
'description' => 'Compay domain from where the SAML requests will come from'
),
'attributes' => array(
'type' => 'blob',
'not null' => FALSE
),
'active' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
'description' => 'Flag to know is a user is active (optional)',
),
),
'primary key' => array('id'),
'unique keys' => array(
'unique_company' => array('company'),
'unique_domain' => array('domain'),
'unique_srcname' => array('source_name'),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function simplesamlphp_auth_install() {
user_role_revoke_permissions(DRUPAL_AUTHENTICATED_RID, array('change own password'));
$original = variable_get( 'user_register', 1 );
variable_set( 'user_register', 0 );
variable_set( 'simplesamlphp_auth_user_register_original', $original );
}
/**
* Implements hook_uninstall().
*/
function simplesamlphp_auth_uninstall() {
/**
* We remove the variables that we set on the system settings form
* @see simplesamlphp_auth_admin.inc
*/
variable_del('simplesamlphp_auth_activate');
variable_del('simplesamlphp_auth_installdir');
variable_del('simplesamlphp_auth_forcehttps');
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_logoutgotourl');
}
/**
* Implements hook_requirements().
*/
function simplesamlphp_auth_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
if (!variable_get('simplesamlphp_auth_activate', 0)) {
$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 = variable_get('simplesamlphp_auth_installdir', '/var/simplesamlphp');
if (!file_exists($basedir . '/lib/_autoload.php')) {
$requirements['simplesamlphp_auth'] = array(
'severity' => REQUIREMENT_WARNING,
'title' => 'simpleSAMLphp_auth',
'value' => t('SimpleSAMLphp authentication is missing the required SimpleSAMLphp library'),
'description' => t('Please download and install the !simplesamlphp library.', array('!simplesamlphp' => l(t('SimpeSAMLphp'), 'https://simplesamlphp.org/download'))),
);
}
}
return $requirements;
}