Skip to content
Snippets Groups Projects
Commit 3c1f4e5b authored by Tim Steiner's avatar Tim Steiner
Browse files

First, add an option in the Site Information config to tell drupal the site can use SSL.

Second, the CAS module will always use SSL when validating a user's ticket.
Third, if a user has any roles other than Anonymous or Authenticated User, they will be given SSL links while "mortal" users will use plain http.

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@227 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent f514dccd
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,18 @@ function unl_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'menu_edit_item' && $form['mlid']['#value'] == 0) {
$form['expanded']['#default_value'] = TRUE;
}
if ($form_id == 'system_site_information_settings') {
$form['site_information']['https'] = array(
'#type' => 'checkbox',
'#title' => 'SSL Enabled',
'#default_value' => variable_get('https', FALSE),
);
$form['#submit'][] = 'unl_system_settings_form_submit';
}
}
function unl_system_settings_form_submit($form, &$form_state) {
variable_set('https', (bool) $form_state['values']['https']);
}
function unl_theme() {
......@@ -136,6 +148,23 @@ function unl_theme() {
);
}
function unl_url_outbound_alter(&$path, &$options, $original_path) {
$path_parts = parse_url($path);
if (isset($path_parts['scheme']) || $path == 'user/cas') {
return;
}
$user = $GLOBALS['user'];
$user_roles = array_keys($user->roles);
$generic_user = TRUE;
foreach ($user_roles as $user_role) {
if (in_array($user_role, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
continue;
}
$generic_user = FALSE;
}
$options['https'] = (bool) (variable_get('https', 0) && !$generic_user);
}
......@@ -31,7 +31,12 @@ function unl_cas_init() {
function unl_cas_get_adapter() {
static $adapter;
if (!$adapter) {
$adapter = new Unl_Cas(url('user/cas', array('absolute' => TRUE)), 'https://login.unl.edu/cas');
if (variable_get('https', FALSE)) {
$url = url('user/cas', array('absolute' => TRUE, 'https' => TRUE));
} else {
$url = url('user/cas', array('absolute' => TRUE));
}
$adapter = new Unl_Cas($url, 'https://login.unl.edu/cas');
}
return $adapter;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment