-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #2427123 by snufkin, jacob.embree: [UX] Breaking out the config…
…uration form into tabs
- Loading branch information
jacob.embree
authored and
Balazs Dianiska
committed
Aug 18, 2015
1 parent
0a73af3
commit 232b1a5
Showing
2 changed files
with
106 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,23 +6,16 @@ | |
*/ | ||
|
||
/** | ||
* Implements settings for the module. | ||
* Basic configuration form. | ||
* | ||
* Shows the first page of SimpleSAMLphp Authentication's configuration. | ||
* | ||
* @return array | ||
*/ | ||
function simplesamlphp_auth_settings() { | ||
global $_simplesamlphp_auth_saml_version, $base_url; | ||
|
||
if (!empty($_simplesamlphp_auth_saml_version)) { | ||
$ver = explode('.', $_simplesamlphp_auth_saml_version); | ||
if (!($ver[0] >= 1 && $ver[1] >= 6)) { | ||
drupal_set_message(t("Please upgrade SimpleSAMLphp. You are using %ssp_version", array('%ssp_version' => $_simplesamlphp_auth_saml_version)), 'warning'); | ||
} | ||
} | ||
|
||
$roles = user_roles(TRUE); | ||
|
||
function simplesamlphp_auth_settings_basic() { | ||
$form['simplesamlphp_auth_grp_setup'] = array( | ||
'#type' => 'fieldset', | ||
'#title' => t('Basic Setup'), | ||
'#title' => t('Basic settings'), | ||
'#collapsible' => FALSE, | ||
); | ||
$form['simplesamlphp_auth_grp_setup']['simplesamlphp_auth_activate'] = array( | ||
|
@@ -56,54 +49,11 @@ function simplesamlphp_auth_settings() { | |
'#description' => t('Path for logging into SAML - Do not include proceeding slash.'), | ||
); | ||
|
||
$form['simplesamlphp_auth_grp_user'] = array( | ||
'#type' => 'fieldset', | ||
'#title' => t('User Info and Syncing'), | ||
'#collapsible' => FALSE, | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_user_name'] = array( | ||
'#type' => 'textfield', | ||
'#title' => t("Which attribute from simpleSAMLphp should be used as user's name"), | ||
'#default_value' => variable_get('simplesamlphp_auth_user_name', 'eduPersonPrincipalName'), | ||
'#description' => t('Example: <i>eduPersonPrincipalName</i> or <i>displayName</i><br />If the attribute is multivalued, the first value will be used.'), | ||
'#required' => TRUE, | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_unique_id'] = array( | ||
'#type' => 'textfield', | ||
'#title' => t('Which attribute from simpleSAMLphp should be used as unique identifier for the user'), | ||
'#default_value' => variable_get('simplesamlphp_auth_unique_id', 'eduPersonPrincipalName'), | ||
'#description' => t('Example: <i>eduPersonPrincipalName</i> or <i>eduPersonTargetedID</i><br />If the attribute is multivalued, the first value will be used.'), | ||
'#required' => TRUE, | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_mailattr'] = array( | ||
'#type' => 'textfield', | ||
'#title' => t('Which attribute from simpleSAMLphp should be used as user mail address'), | ||
'#default_value' => variable_get('simplesamlphp_auth_mailattr', 'mail'), | ||
'#description' => t('Example: <i>mail</i><br />If the user attribute is multivalued, the first value will be used.'), | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_rolepopulation'] = array( | ||
'#type' => 'textarea', | ||
'#title' => t('Automatic role population from simpleSAMLphp attributes'), | ||
'#default_value' => variable_get('simplesamlphp_auth_rolepopulation', ''), | ||
'#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'), | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_roleevaleverytime'] = array( | ||
'#type' => 'checkbox', | ||
'#title' => t('Reevaluate roles every time the user logs in.'), | ||
'#default_value' => variable_get('simplesamlphp_auth_roleevaleverytime', 0), | ||
'#description' => t('NOTE: This means users could loose any roles that have been assigned manually in Drupal.'), | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_autoenablesaml'] = array( | ||
'#type' => 'checkbox', | ||
'#title' => t('Automatically enable SAML authentication for existing users upon successful login'), | ||
'#default_value' => variable_get('simplesamlphp_auth_autoenablesaml', 0), | ||
); | ||
|
||
$form['simplesamlphp_auth_grp_reg'] = array( | ||
'#type' => 'fieldset', | ||
'#title' => t('User Provisioning'), | ||
'#collapsible' => TRUE, | ||
'#collapsed' => TRUE, | ||
'#collapsible' => FALSE, | ||
'#collapsed' => FALSE, | ||
); | ||
$form['simplesamlphp_auth_grp_reg']['simplesamlphp_auth_registerusers'] = array( | ||
'#type' => 'checkbox', | ||
|
@@ -112,11 +62,21 @@ function simplesamlphp_auth_settings() { | |
'#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."), | ||
); | ||
|
||
return system_settings_form($form); | ||
} | ||
|
||
/** | ||
* Configuration form for all local authentication related settings. | ||
* | ||
* @return array | ||
*/ | ||
function simplesamlphp_auth_settings_local() { | ||
$roles = user_roles(TRUE); | ||
$form['simplesamlphp_auth_grp_auth'] = array( | ||
'#type' => 'fieldset', | ||
'#title' => t('Drupal Authentication'), | ||
'#collapsible' => TRUE, | ||
'#collapsed' => TRUE, | ||
'#collapsible' => FALSE, | ||
'#collapsed' => FALSE, | ||
); | ||
$form['simplesamlphp_auth_grp_auth']['simplesamlphp_auth_allowdefaultlogin'] = array( | ||
'#type' => 'checkbox', | ||
|
@@ -154,23 +114,75 @@ function simplesamlphp_auth_settings() { | |
'#type' => 'textfield', | ||
'#title' => t('Optionally, specify a URL for users to go to after logging out'), | ||
'#default_value' => variable_get('simplesamlphp_auth_logoutgotourl', ''), | ||
'#description' => t('Example: @base_url', array('@base_url' => $base_url)), | ||
'#description' => t('Example: @base_url', array('@base_url' => $GLOBALS['base_url'])), | ||
); | ||
|
||
$form['#submit'][] = 'simplesamlphp_auth_settings_submit'; | ||
$form['#submit'][] = 'simplesamlphp_auth_settings_local_submit'; | ||
|
||
return system_settings_form($form); | ||
} | ||
|
||
/** | ||
* Configuration form pertaining to how the data is pulled in from the IdP. | ||
* | ||
* @return array | ||
*/ | ||
function simplesamlphp_auth_settings_sync() { | ||
$form['simplesamlphp_auth_grp_user'] = array( | ||
'#type' => 'fieldset', | ||
'#title' => t('User Info and Syncing'), | ||
'#collapsible' => FALSE, | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_user_name'] = array( | ||
'#type' => 'textfield', | ||
'#title' => t("Which attribute from simpleSAMLphp should be used as user's name"), | ||
'#default_value' => variable_get('simplesamlphp_auth_user_name', 'eduPersonPrincipalName'), | ||
'#description' => t('Example: <i>eduPersonPrincipalName</i> or <i>displayName</i><br />If the attribute is multivalued, the first value will be used.'), | ||
'#required' => TRUE, | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_unique_id'] = array( | ||
'#type' => 'textfield', | ||
'#title' => t('Which attribute from simpleSAMLphp should be used as unique identifier for the user'), | ||
'#default_value' => variable_get('simplesamlphp_auth_unique_id', 'eduPersonPrincipalName'), | ||
'#description' => t('Example: <i>eduPersonPrincipalName</i> or <i>eduPersonTargetedID</i><br />If the attribute is multivalued, the first value will be used.'), | ||
'#required' => TRUE, | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_mailattr'] = array( | ||
'#type' => 'textfield', | ||
'#title' => t('Which attribute from simpleSAMLphp should be used as user mail address'), | ||
'#default_value' => variable_get('simplesamlphp_auth_mailattr', 'mail'), | ||
'#description' => t('Example: <i>mail</i><br />If the user attribute is multivalued, the first value will be used.'), | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_rolepopulation'] = array( | ||
'#type' => 'textarea', | ||
'#title' => t('Automatic role population from simpleSAMLphp attributes'), | ||
'#default_value' => variable_get('simplesamlphp_auth_rolepopulation', ''), | ||
'#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'), | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_roleevaleverytime'] = array( | ||
'#type' => 'checkbox', | ||
'#title' => t('Reevaluate roles every time the user logs in.'), | ||
'#default_value' => variable_get('simplesamlphp_auth_roleevaleverytime', 0), | ||
'#description' => t('NOTE: This means users could loose any roles that have been assigned manually in Drupal.'), | ||
); | ||
$form['simplesamlphp_auth_grp_user']['simplesamlphp_auth_autoenablesaml'] = array( | ||
'#type' => 'checkbox', | ||
'#title' => t('Automatically enable SAML authentication for existing users upon successful login'), | ||
'#default_value' => variable_get('simplesamlphp_auth_autoenablesaml', 0), | ||
); | ||
|
||
return system_settings_form($form); | ||
} | ||
|
||
/** | ||
* Additional submission handler for simplesamlphp_auth_settings(). | ||
* Additional submission handler for simplesamlphp_auth_settings_local(). | ||
* | ||
* If there is a change in the login path, trigger a menu rebuild. | ||
* | ||
* @see simplesamlphp_auth_settings() | ||
* @see simplesamlphp_auth_settings_local() | ||
* @see system_settings_form_submit() | ||
*/ | ||
function simplesamlphp_auth_settings_submit($form, &$form_state) { | ||
function simplesamlphp_auth_settings_local_submit($form, &$form_state) { | ||
$old_login_path = variable_get('simplesamlphp_auth_login_path', 'saml_login'); | ||
$new_login_path = $form_state['values']['simplesamlphp_auth_login_path']; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters