Skip to content

Commit

Permalink
Merge pull request #560 from City-of-Helsinki/revert-556-UHF-9531-sep…
Browse files Browse the repository at this point in the history
…arate-client-for-edu

Revert "UHF-9531: Add separate client for edu users"
  • Loading branch information
hyrsky authored Jan 30, 2024
2 parents 3d2dbad + f3bf032 commit f48cc78
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 61 deletions.
21 changes: 0 additions & 21 deletions conf/cmi/openid_connect.client.keycloak.yml

This file was deleted.

2 changes: 1 addition & 1 deletion conf/cmi/openid_connect.client.tunnistamo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
_core:
default_config_hash: nGpk9fP8YMhP_c3Sz_aCQFVhAJyN6eJI6E4Qpnqna-A
id: tunnistamo
label: edu.hel.fi
label: Tunnistamo
plugin: tunnistamo
settings:
client_id: placeholder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\helfi_kasko_content\UnitCategoryUtility;
use Drupal\helfi_platform_config\DTO\ParagraphTypeCollection;
use Drupal\paragraphs\ParagraphInterface;
use Drupal\user\UserInterface;

/**
* Implements hook_ENTITY_TYPE_access().
Expand Down Expand Up @@ -338,30 +336,3 @@ function helfi_kasko_content_views_data_alter(array &$data) {
],
];
}

/**
* Implements hook_openid_connect_pre_authorize().
*/
function helfi_kasko_content_openid_connect_pre_authorize(UserInterface|bool $account, array $context) : bool {
$pluginId = $context['plugin_id'];
$userinfo = $context['userinfo'] ?? NULL;
$email = $userinfo['email'] ?? NULL;

// Helsinki-profiili has issues with edu.hel.fi users:
// https://helsinkisolutionoffice.atlassian.net/browse/HP-2147.
// As a workaround, kasko has a separate client that still uses old
// Tunnistamo. This prevents non edu.hel.fi users from using tunnistamo.
// @todo remove when edu.hel.fi clients work with Helsinki-profiili.
$allowLogin = match ($pluginId) {
'tunnistamo' => $email === helfi_tunnistamo_create_email($userinfo),
'keycloak' => $email !== helfi_tunnistamo_create_email($userinfo),
default => TRUE,
};

if (!$allowLogin && $pluginId === 'tunnistamo') {
\Drupal::messenger()
->addError(new TranslatableMarkup("Only edu.hel.fi users are allowed to log in with this method."));
}

return $allowLogin;
}
3 changes: 0 additions & 3 deletions public/modules/custom/helfi_kasko_content/translations/fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,3 @@ msgstr "B2-kieli"
msgctxt "TPR Ontologyword details schools"
msgid "Language offering"
msgstr "Kielitarjonta"

msgid "Only edu.hel.fi users are allowed to log in with this method"
msgstr "Vain edu.hel.fi käyttäjät voivat kirjautua tällä kirjautumistavalla."
7 changes: 0 additions & 7 deletions public/sites/default/all.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,3 @@

// Sentry DSN for React.
$config['react_search.settings']['sentry_dsn_react'] = getenv('SENTRY_DSN_REACT');

// @todo remove separate client once edu.hel.fi users work with keycloak.
$config['openid_connect.client.keycloak']['settings']['client_id'] = getenv('KEYCLOAK_CLIENT_ID');
$config['openid_connect.client.keycloak']['settings']['client_secret'] = getenv('KEYCLOAK_CLIENT_SECRET');
if ($keycloak_environment_url = getenv('KEYCLOAK_ENVIRONMENT_URL')) {
$config['openid_connect.client.keycloak']['settings']['environment_url'] = $keycloak_environment_url;
}

0 comments on commit f48cc78

Please sign in to comment.