-
Notifications
You must be signed in to change notification settings - Fork 26
feat(stepup): add service display name to Stepup callout AuthnRequest #2034
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
Open
kayjoosten
wants to merge
2
commits into
main
Choose a base branch
from
feature/issue-2011-stepup-display-name
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| use OpenConext\EngineBlock\Metadata\Service; | ||
| use OpenConext\EngineBlock\Metadata\TransparentMfaEntity; | ||
| use OpenConext\EngineBlock\Stepup\StepupGsspUserAttributeExtension; | ||
| use OpenConext\EngineBlock\Stepup\StepupServiceNameExtension; | ||
| use OpenConext\EngineBlock\Metadata\X509\KeyPairFactory; | ||
| use OpenConext\EngineBlockBundle\Authentication\AuthenticationState; | ||
| use OpenConext\EngineBlockBundle\Exception\UnknownKeyIdException; | ||
|
|
@@ -486,7 +487,8 @@ public function sendStepupAuthenticationRequest( | |
| Loa $authnContextClassRef, | ||
| NameID $nameId, | ||
| bool $isForceAuthn, | ||
| Assertion $originalAssertion | ||
| Assertion $originalAssertion, | ||
| ?ServiceProvider $sp = null, | ||
|
johanib marked this conversation as resolved.
|
||
| ): void { | ||
| $ebRequest = EngineBlock_Saml2_AuthnRequestFactory::createFromRequest( | ||
| $spRequest, | ||
|
|
@@ -555,6 +557,19 @@ public function sendStepupAuthenticationRequest( | |
| } | ||
| } | ||
|
|
||
| $isSendServiceNameConfigured = $features->hasFeature('eb.stepup.send_service_name'); | ||
|
johanib marked this conversation as resolved.
|
||
| $isSendServiceNameEnabled = $features->isEnabled('eb.stepup.send_service_name'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move to inline if, so it doesnt get called if feature flag is not set |
||
|
|
||
| if ($isSendServiceNameConfigured && $isSendServiceNameEnabled && $sp !== null) { | ||
| $localeProvider = $container->getLocaleProvider(); | ||
| StepupServiceNameExtension::add( | ||
| $sspMessage, | ||
| $sp, | ||
| $localeProvider->getLocale(), | ||
| $localeProvider->getDefaultLocale(), | ||
| $localeProvider->getAvailableLocales(), | ||
| ); | ||
| } | ||
|
|
||
| // Link with the original Request | ||
| $diContainerRuntime = EngineBlock_ApplicationSingleton::getInstance()->getDiContainerRuntime(); | ||
|
|
@@ -635,6 +650,7 @@ public function handleStepupAuthenticationCallout( | |
| $nameId, | ||
| $sp->getCoins()->isStepupForceAuthn(), | ||
| $originalAssertion, | ||
| $sp, | ||
| ); | ||
| } | ||
|
|
||
|
|
||
90 changes: 90 additions & 0 deletions
90
src/OpenConext/EngineBlock/Stepup/StepupServiceNameExtension.php
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Copyright 2026 SURFnet B.V. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OpenConext\EngineBlock\Stepup; | ||
|
|
||
| use OpenConext\EngineBlock\Metadata\Entity\ServiceProvider; | ||
| use SAML2\DOMDocumentFactory; | ||
| use SAML2\Message; | ||
| use SAML2\XML\Chunk; | ||
|
|
||
| final class StepupServiceNameExtension | ||
| { | ||
| private const MDUI_NS = 'urn:oasis:names:tc:SAML:metadata:ui'; | ||
|
|
||
| /** | ||
| * @param string[] $availableLocales | ||
| */ | ||
| public static function add( | ||
| Message $message, | ||
| ServiceProvider $sp, | ||
| string $locale, | ||
| string $defaultLocale, | ||
| array $availableLocales, | ||
| ): void { | ||
| if (!in_array($locale, $availableLocales, true)) { | ||
| $locale = $defaultLocale; | ||
| } | ||
| $result = self::resolveName($sp, $locale); | ||
| if ($result === null && $locale !== $defaultLocale) { | ||
| $result = self::resolveName($sp, $defaultLocale); | ||
| } | ||
| if ($result === null) { | ||
| return; | ||
| } | ||
| [$resolvedLocale, $name] = $result; | ||
|
|
||
| $dom = DOMDocumentFactory::create(); | ||
| $uiInfo = $dom->createElementNS(self::MDUI_NS, 'mdui:UIInfo'); | ||
| $displayName = $dom->createElementNS(self::MDUI_NS, 'mdui:DisplayName'); | ||
| $displayName->setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:lang', $resolvedLocale); | ||
| $displayName->textContent = $name; | ||
| $uiInfo->appendChild($displayName); | ||
|
|
||
| $ext = $message->getExtensions(); | ||
| $ext['mdui:UIInfo'] = new Chunk($uiInfo); | ||
|
johanib marked this conversation as resolved.
|
||
| $message->setExtensions($ext); | ||
| } | ||
|
|
||
| /** | ||
| * @return array{string, string}|null | ||
| */ | ||
| private static function resolveName(ServiceProvider $sp, string $locale): ?array | ||
|
johanib marked this conversation as resolved.
|
||
| { | ||
| $name = $sp->getMdui()->getDisplayNameOrNull($locale); | ||
| if (empty($name)) { | ||
| $name = self::localizedName($sp, $locale); | ||
| } | ||
| if (empty($name)) { | ||
| return null; | ||
| } | ||
| return [$locale, $name]; | ||
| } | ||
|
|
||
| private static function localizedName(ServiceProvider $sp, string $locale): ?string | ||
| { | ||
| return match ($locale) { | ||
| 'en' => $sp->nameEn, | ||
| 'nl' => $sp->nameNl, | ||
| 'pt' => $sp->namePt, | ||
| default => null, | ||
| }; | ||
| } | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.