Skip to content

Commit

Permalink
Merge pull request #13 from CU-CommunityApps/local_login_fixes
Browse files Browse the repository at this point in the history
Bug Fixes - local login
  • Loading branch information
judaw authored Oct 31, 2023
2 parents 0ebf412 + d3e534f commit 33488ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions cwd_saml_mapping.module
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function cwd_saml_mapping_saml_sp_drupal_login_user_attributes_alter($user, $att
$values = explode("\r\n", $role_assigment_config->get('values'));


//Catch condition the proptery is not release to us from shibboleth (ex. Test Shibboleth does no release groups property)
//Catch condition the property is not release to us from shibboleth (ex. Test Shibboleth does no release groups property)
if (!array_key_exists($samlprop, $attributes)) {
$missing_property_messages[] = $saml_property_mappings[$samlprop] . " => " . $role_assigment_config->get('id');
$rolesUnableToEvaluateForRemoval[] = $role;
Expand Down Expand Up @@ -68,7 +68,7 @@ function cwd_saml_mapping_saml_sp_drupal_login_user_attributes_alter($user, $att

//Log message about configurations with missing properties
if(count($missing_property_messages) > 0) {
$message = "Proptery not found in Shibboleth data found for [" . implode("] , [", $missing_property_messages) . "]";
$message = "Property not found in Shibboleth data found for [" . implode("] , [", $missing_property_messages) . "]";
\Drupal::logger('cwd_saml_mapping')->info($message);
}

Expand Down Expand Up @@ -176,7 +176,13 @@ function cwd_saml_mapping_preprocess_item_list(&$variables) {
$is_prod_and_use_prod_shibboleth = (isset($_ENV['PANTHEON_ENVIRONMENT']) && $_ENV['PANTHEON_ENVIRONMENT'] === 'live' && $use_saml_in_prod);
if ($is_prod_and_use_prod_shibboleth) {
//Loop through links and remove ones that contain 'test'
foreach ($variables['items'] as $index => $link) {
foreach ($variables['items'] as $index => $link) {
if (gettype($link['value']) != "object") {
continue;
}
elseif (get_class($link['value']) != "Drupal\Core\Link") {
continue;
}
$idp_name = $link['value']->getText()->getArguments()['%idp'] ?? null;
$idp_class = strtolower(preg_replace("/\s+/", "_", $idp_name));
if ($idp_name && str_contains(strtolower(($idp_name)), "test") && !$show_all_idps) {
Expand All @@ -192,6 +198,12 @@ function cwd_saml_mapping_preprocess_item_list(&$variables) {
else {
//Loop through links and remove ones that contain 'prod'
foreach ($variables['items'] as $index => $link) {
if (gettype($link['value']) != "object") {
continue;
}
elseif (get_class($link['value']) != "Drupal\Core\Link") {
continue;
}
$idp_name = $link['value']->getText()->getArguments()['%idp'] ?? null;
$idp_class = strtolower(preg_replace("/\s+/", "_", $idp_name));
if ($idp_name && str_contains(strtolower(($idp_name)), "prod") && !$show_all_idps) {
Expand Down
2 changes: 1 addition & 1 deletion src/Form/CWDSamlMappingConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
];
$form['customize_links']['show_all_idps'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show All IDPs to that can be used.'),
'#title' => $this->t('Show All IDPs that can be used.'),
'#default_value' => $config->get('show_all_idps'),
];
$form['customize_links']['hide_drupal_login'] = [
Expand Down

0 comments on commit 33488ea

Please sign in to comment.