Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "UHF-9531: Add separate client for edu users" #560

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading