6
6
*/
7
7
8
8
/**
9
- * Implements settings for the module.
9
+ * Basic configuration form.
10
+ *
11
+ * Shows the first page of SimpleSAMLphp Authentication's configuration.
12
+ *
13
+ * @return array
10
14
*/
11
- function simplesamlphp_auth_settings () {
12
- global $ _simplesamlphp_auth_saml_version , $ base_url ;
13
-
14
- if (!empty ($ _simplesamlphp_auth_saml_version )) {
15
- $ ver = explode ('. ' , $ _simplesamlphp_auth_saml_version );
16
- if (!($ ver [0 ] >= 1 && $ ver [1 ] >= 6 )) {
17
- drupal_set_message (t ("Please upgrade SimpleSAMLphp. You are using %ssp_version " , array ('%ssp_version ' => $ _simplesamlphp_auth_saml_version )), 'warning ' );
18
- }
19
- }
20
-
21
- $ roles = user_roles (TRUE );
22
-
15
+ function simplesamlphp_auth_settings_basic () {
23
16
$ form ['simplesamlphp_auth_grp_setup ' ] = array (
24
17
'#type ' => 'fieldset ' ,
25
- '#title ' => t ('Basic Setup ' ),
18
+ '#title ' => t ('Basic settings ' ),
26
19
'#collapsible ' => FALSE ,
27
20
);
28
21
$ form ['simplesamlphp_auth_grp_setup ' ]['simplesamlphp_auth_activate ' ] = array (
@@ -56,54 +49,11 @@ function simplesamlphp_auth_settings() {
56
49
'#description ' => t ('Path for logging into SAML - Do not include proceeding slash. ' ),
57
50
);
58
51
59
- $ form ['simplesamlphp_auth_grp_user ' ] = array (
60
- '#type ' => 'fieldset ' ,
61
- '#title ' => t ('User Info and Syncing ' ),
62
- '#collapsible ' => FALSE ,
63
- );
64
- $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_user_name ' ] = array (
65
- '#type ' => 'textfield ' ,
66
- '#title ' => t ("Which attribute from simpleSAMLphp should be used as user's name " ),
67
- '#default_value ' => variable_get ('simplesamlphp_auth_user_name ' , 'eduPersonPrincipalName ' ),
68
- '#description ' => t ('Example: <i>eduPersonPrincipalName</i> or <i>displayName</i><br />If the attribute is multivalued, the first value will be used. ' ),
69
- '#required ' => TRUE ,
70
- );
71
- $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_unique_id ' ] = array (
72
- '#type ' => 'textfield ' ,
73
- '#title ' => t ('Which attribute from simpleSAMLphp should be used as unique identifier for the user ' ),
74
- '#default_value ' => variable_get ('simplesamlphp_auth_unique_id ' , 'eduPersonPrincipalName ' ),
75
- '#description ' => t ('Example: <i>eduPersonPrincipalName</i> or <i>eduPersonTargetedID</i><br />If the attribute is multivalued, the first value will be used. ' ),
76
- '#required ' => TRUE ,
77
- );
78
- $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_mailattr ' ] = array (
79
- '#type ' => 'textfield ' ,
80
- '#title ' => t ('Which attribute from simpleSAMLphp should be used as user mail address ' ),
81
- '#default_value ' => variable_get ('simplesamlphp_auth_mailattr ' , 'mail ' ),
82
- '#description ' => t ('Example: <i>mail</i><br />If the user attribute is multivalued, the first value will be used. ' ),
83
- );
84
- $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_rolepopulation ' ] = array (
85
- '#type ' => 'textarea ' ,
86
- '#title ' => t ('Automatic role population from simpleSAMLphp attributes ' ),
87
- '#default_value ' => variable_get ('simplesamlphp_auth_rolepopulation ' , '' ),
88
- '#description ' =>
t (
'A pipe separated list of rules.<br />Example: <i>roleid1:condition1|roleid2:contition2...</i> <br />For instance: <i>1:eduPersonPrincipalName,@=,uninett.no;affiliation,=,employee|2:mail,=,[email protected] </i>,3:mail,~=,andre ' ),
89
- );
90
- $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_roleevaleverytime ' ] = array (
91
- '#type ' => 'checkbox ' ,
92
- '#title ' => t ('Reevaluate roles every time the user logs in. ' ),
93
- '#default_value ' => variable_get ('simplesamlphp_auth_roleevaleverytime ' , 0 ),
94
- '#description ' => t ('NOTE: This means users could loose any roles that have been assigned manually in Drupal. ' ),
95
- );
96
- $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_autoenablesaml ' ] = array (
97
- '#type ' => 'checkbox ' ,
98
- '#title ' => t ('Automatically enable SAML authentication for existing users upon successful login ' ),
99
- '#default_value ' => variable_get ('simplesamlphp_auth_autoenablesaml ' , 0 ),
100
- );
101
-
102
52
$ form ['simplesamlphp_auth_grp_reg ' ] = array (
103
53
'#type ' => 'fieldset ' ,
104
54
'#title ' => t ('User Provisioning ' ),
105
- '#collapsible ' => TRUE ,
106
- '#collapsed ' => TRUE ,
55
+ '#collapsible ' => FALSE ,
56
+ '#collapsed ' => FALSE ,
107
57
);
108
58
$ form ['simplesamlphp_auth_grp_reg ' ]['simplesamlphp_auth_registerusers ' ] = array (
109
59
'#type ' => 'checkbox ' ,
@@ -112,11 +62,21 @@ function simplesamlphp_auth_settings() {
112
62
'#description ' => t ("Determines wether or not the module should automatically create/register new Drupal accounts for users that authenticate using SimpleSAMLphp. Unless you've done some custom work to provision Drupal accounts with the necessary authmap entries you will want this checked. NOTE: If unchecked each user must already have been provisioned a Drupal account with an appropriate entry in the authmap table before logging in. Otherwise they will receive a notice and be denied access. Be aware that simply creating a Drupal account will not create the necessary entry in the authmap table. " ),
113
63
);
114
64
65
+ return system_settings_form ($ form );
66
+ }
67
+
68
+ /**
69
+ * Configuration form for all local authentication related settings.
70
+ *
71
+ * @return array
72
+ */
73
+ function simplesamlphp_auth_settings_local () {
74
+ $ roles = user_roles (TRUE );
115
75
$ form ['simplesamlphp_auth_grp_auth ' ] = array (
116
76
'#type ' => 'fieldset ' ,
117
77
'#title ' => t ('Drupal Authentication ' ),
118
- '#collapsible ' => TRUE ,
119
- '#collapsed ' => TRUE ,
78
+ '#collapsible ' => FALSE ,
79
+ '#collapsed ' => FALSE ,
120
80
);
121
81
$ form ['simplesamlphp_auth_grp_auth ' ]['simplesamlphp_auth_allowdefaultlogin ' ] = array (
122
82
'#type ' => 'checkbox ' ,
@@ -154,23 +114,75 @@ function simplesamlphp_auth_settings() {
154
114
'#type ' => 'textfield ' ,
155
115
'#title ' => t ('Optionally, specify a URL for users to go to after logging out ' ),
156
116
'#default_value ' => variable_get ('simplesamlphp_auth_logoutgotourl ' , '' ),
157
- '#description ' => t ('Example: @base_url ' , array ('@base_url ' => $ base_url )),
117
+ '#description ' => t ('Example: @base_url ' , array ('@base_url ' => $ GLOBALS [ ' base_url ' ] )),
158
118
);
159
119
160
- $ form ['#submit ' ][] = 'simplesamlphp_auth_settings_submit ' ;
120
+ $ form ['#submit ' ][] = 'simplesamlphp_auth_settings_local_submit ' ;
121
+
122
+ return system_settings_form ($ form );
123
+ }
124
+
125
+ /**
126
+ * Configuration form pertaining to how the data is pulled in from the IdP.
127
+ *
128
+ * @return array
129
+ */
130
+ function simplesamlphp_auth_settings_sync () {
131
+ $ form ['simplesamlphp_auth_grp_user ' ] = array (
132
+ '#type ' => 'fieldset ' ,
133
+ '#title ' => t ('User Info and Syncing ' ),
134
+ '#collapsible ' => FALSE ,
135
+ );
136
+ $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_user_name ' ] = array (
137
+ '#type ' => 'textfield ' ,
138
+ '#title ' => t ("Which attribute from simpleSAMLphp should be used as user's name " ),
139
+ '#default_value ' => variable_get ('simplesamlphp_auth_user_name ' , 'eduPersonPrincipalName ' ),
140
+ '#description ' => t ('Example: <i>eduPersonPrincipalName</i> or <i>displayName</i><br />If the attribute is multivalued, the first value will be used. ' ),
141
+ '#required ' => TRUE ,
142
+ );
143
+ $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_unique_id ' ] = array (
144
+ '#type ' => 'textfield ' ,
145
+ '#title ' => t ('Which attribute from simpleSAMLphp should be used as unique identifier for the user ' ),
146
+ '#default_value ' => variable_get ('simplesamlphp_auth_unique_id ' , 'eduPersonPrincipalName ' ),
147
+ '#description ' => t ('Example: <i>eduPersonPrincipalName</i> or <i>eduPersonTargetedID</i><br />If the attribute is multivalued, the first value will be used. ' ),
148
+ '#required ' => TRUE ,
149
+ );
150
+ $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_mailattr ' ] = array (
151
+ '#type ' => 'textfield ' ,
152
+ '#title ' => t ('Which attribute from simpleSAMLphp should be used as user mail address ' ),
153
+ '#default_value ' => variable_get ('simplesamlphp_auth_mailattr ' , 'mail ' ),
154
+ '#description ' => t ('Example: <i>mail</i><br />If the user attribute is multivalued, the first value will be used. ' ),
155
+ );
156
+ $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_rolepopulation ' ] = array (
157
+ '#type ' => 'textarea ' ,
158
+ '#title ' => t ('Automatic role population from simpleSAMLphp attributes ' ),
159
+ '#default_value ' => variable_get ('simplesamlphp_auth_rolepopulation ' , '' ),
160
+ '#description ' =>
t (
'A pipe separated list of rules.<br />Example: <i>roleid1:condition1|roleid2:contition2...</i> <br />For instance: <i>1:eduPersonPrincipalName,@=,uninett.no;affiliation,=,employee|2:mail,=,[email protected] </i>,3:mail,~=,andre ' ),
161
+ );
162
+ $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_roleevaleverytime ' ] = array (
163
+ '#type ' => 'checkbox ' ,
164
+ '#title ' => t ('Reevaluate roles every time the user logs in. ' ),
165
+ '#default_value ' => variable_get ('simplesamlphp_auth_roleevaleverytime ' , 0 ),
166
+ '#description ' => t ('NOTE: This means users could loose any roles that have been assigned manually in Drupal. ' ),
167
+ );
168
+ $ form ['simplesamlphp_auth_grp_user ' ]['simplesamlphp_auth_autoenablesaml ' ] = array (
169
+ '#type ' => 'checkbox ' ,
170
+ '#title ' => t ('Automatically enable SAML authentication for existing users upon successful login ' ),
171
+ '#default_value ' => variable_get ('simplesamlphp_auth_autoenablesaml ' , 0 ),
172
+ );
161
173
162
174
return system_settings_form ($ form );
163
175
}
164
176
165
177
/**
166
- * Additional submission handler for simplesamlphp_auth_settings ().
178
+ * Additional submission handler for simplesamlphp_auth_settings_local ().
167
179
*
168
180
* If there is a change in the login path, trigger a menu rebuild.
169
181
*
170
- * @see simplesamlphp_auth_settings ()
182
+ * @see simplesamlphp_auth_settings_local ()
171
183
* @see system_settings_form_submit()
172
184
*/
173
- function simplesamlphp_auth_settings_submit ($ form , &$ form_state ) {
185
+ function simplesamlphp_auth_settings_local_submit ($ form , &$ form_state ) {
174
186
$ old_login_path = variable_get ('simplesamlphp_auth_login_path ' , 'saml_login ' );
175
187
$ new_login_path = $ form_state ['values ' ]['simplesamlphp_auth_login_path ' ];
176
188
0 commit comments