Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
23a7b63
Preserve and expose mdui:UIInfo during authentication and registration
kayjoosten Jul 2, 2026
604d096
Point surfnet/stepup-saml-bundle to feature branch for integration te…
kayjoosten Jul 2, 2026
d9c1b2d
Expose mdui:UIInfo via AuthenticationService::getMdui()
kayjoosten Jul 2, 2026
bd8d55b
Add getMdui() accessor to RegistrationService
kayjoosten Jul 2, 2026
a6d0c38
Clarify pre-existing service-name scenario is unrelated to mdui:UIInfo
kayjoosten Jul 3, 2026
478ec76
Document composer audit ignores for transitive simplesamlphp/saml2 ad…
kayjoosten Jul 3, 2026
c1c8afd
Drop stale composer audit ignores for already-patched saml2 advisories
kayjoosten Jul 8, 2026
ab0e713
Remove audit.ignore block entirely, advisories are already patched
kayjoosten Jul 8, 2026
efdd21e
Revert "Remove audit.ignore block entirely, advisories are already pa…
kayjoosten Jul 8, 2026
c6f1b2a
Preserve and expose mdui:UIInfo
kayjoosten Jul 10, 2026
049107f
Fix service name formatter deleting tabs/newlines instead of collapsi…
kayjoosten Jul 14, 2026
26f1b60
Merge remote-tracking branch 'origin/feature/issue-48-preserve-mdui-u…
kayjoosten Jul 14, 2026
f90e3a5
fix: correct off-by-one truncation in ServiceNameFormatter (40 chars …
kayjoosten Jul 27, 2026
ce8aab1
fix: update ResolverTest assertion for corrected ServiceNameFormatter…
kayjoosten Jul 27, 2026
536f69f
Document the mdui:UIInfo / ServiceName feature ahead of release
kayjoosten Jul 27, 2026
26e1ee4
Use stepup-saml-bundle's ServiceNameFormatter instead of a local dupl…
kayjoosten Jul 30, 2026
664d0cd
fix: quote PHPMD annotation so phpstan can parse it
kayjoosten Aug 3, 2026
72f8ff1
Swap stepup-saml-bundle dev-branch pin for tagged beta release
kayjoosten Aug 3, 2026
d2bb268
feat: add hasMdui() to service interfaces, drop dev-branch pin
kayjoosten Aug 6, 2026
564a064
Merge branch 'main' into feature/issue-48-preserve-mdui-uiinfo
kayjoosten Oct 26, 2026
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

- Add support for PHP 8.5
- Keep the minimum required PHP version at ^8.2
- New: preserve and expose the `mdui:UIInfo` SAML extension (service display name) from the AuthnRequest during
authentication and registration, via `StateHandlerInterface::getMdui()`/`hasMdui()` and
`AuthenticationService::getMdui()`/`RegistrationService::getMdui()`.
- New: `Surfnet\GsspBundle\Service\ServiceName\ServiceNameFormatter` and `ServiceNameResolver` sanitize and
locale-match a resolved display name. Contract: truncated to 40 characters total (39 characters + ellipsis when
truncated), whitespace trimmed/collapsed, control/format characters stripped, locale fallback order is exact match
-> `en` -> first available `DisplayName`.
- Not yet tagged/released.

# 6.0.0

Expand Down
15 changes: 14 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"license": "Apache-2.0",
"description": "A Symfony 6 bundle to aid the creation of GSSP (Generic SAML Step-up Provider) device support.",
"type": "symfony-bundle",
"prefer-stable": true,
"repositories": [
{
"type": "vcs",
"url": "https://github.com/OpenConext/Stepup-saml-bundle"
}
],
"autoload": {
"psr-4": {
"Surfnet\\GsspBundle\\": "src"
Expand All @@ -20,7 +27,7 @@
"php": "^8.2",
"ext-openssl": "*",
"beberlei/assert": "^3",
"surfnet/stepup-saml-bundle": "^7.0",
"surfnet/stepup-saml-bundle": "7.1.0-beta3",
"symfony/dependency-injection": "^7.4",
"symfony/framework-bundle": "^7.4",
"symfony/http-foundation": "^7.4",
Expand Down Expand Up @@ -74,6 +81,12 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"simplesamlphp/composer-xmlprovider-installer": false
},
"audit": {
"ignore": {
"PKSA-1fc7-xrz7-vw78": "GHSA-5cjr-mxj5-wmrx: DoS via XPath Transform in ds:Signature processing (transitive via surfnet/stepup-saml-bundle -> simplesamlphp/saml2). No patched simplesamlphp/saml2 4.x release exists or is planned. Mitigated in surfnet/stepup-saml-bundle by Surfnet\\SamlBundle\\Signing\\SignatureTransformGuard, called from PostBinding::processResponse() before every signature verification. See Stepup-saml-bundle PR #137.",
"PKSA-yk3g-3g3t-ts6q": "GHSA-6929-8p9f-26jx: TLS validator confusion in HTTP-Artifact binding resolution (transitive via surfnet/stepup-saml-bundle -> simplesamlphp/saml2). Neither this bundle nor surfnet/stepup-saml-bundle implement HTTP-Artifact binding; the affected code path is unreachable."
}
}
}
}
4 changes: 2 additions & 2 deletions src/Controller/SSOController.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ private function registrationAction(Request $request, ReceivedAuthnRequest $orig
*/
private function getRelayStateFromRequest(Request $request): string
{
if (!is_string($request->get(AuthnRequest::PARAMETER_RELAY_STATE))) {
if (!is_string($request->query->get(AuthnRequest::PARAMETER_RELAY_STATE))) {
return '';
}
return $request->get(AuthnRequest::PARAMETER_RELAY_STATE);
return $request->query->get(AuthnRequest::PARAMETER_RELAY_STATE);
}
}
65 changes: 64 additions & 1 deletion src/Features/Context/GsspContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
use SAML2\XML\saml\NameID;
use Surfnet\GsspBundle\Controller\SSOController;
use Surfnet\GsspBundle\Controller\SSOReturnController;
use Surfnet\SamlBundle\SAML2\Extensions\Extensions;
use Surfnet\SamlBundle\SAML2\Extensions\GsspUserAttributesChunk;
use Surfnet\SamlBundle\SAML2\Extensions\MduiChunk;
use SAML2\XML\Chunk as SAML2Chunk;
use Surfnet\GsspBundle\Logger\StepupRequestIdSariLogger;
use Surfnet\GsspBundle\Saml\AssertionSigningService;
use Surfnet\GsspBundle\Saml\ResponseContext;
Expand Down Expand Up @@ -113,6 +117,8 @@ final class GsspContext implements Context

private ?Exception $lastException = null;

private ?StateHandler $stateHandler = null;

/**
* Every scenario we start with a clean slate.
*
Expand All @@ -129,7 +135,7 @@ public function bootstrapDependencies(): void
$this->twigTemplate = null;

// Create required dependencies.
$stateHandler = new StateHandler(new InMemoryValueStore());
$this->stateHandler = $stateHandler = new StateHandler(new InMemoryValueStore());
$this->logger = new BufferingLogger();
$logger = new StepupRequestIdSariLogger(
$this->logger,
Expand Down Expand Up @@ -618,6 +624,30 @@ public function theIdentityProviderSetsAnError($message): void
$this->registrationService->replyToServiceProvider();
}

#[Given('the AuthnRequest contains service name :serviceName')]
public function setServiceNameOnAuthnRequest(string $serviceName): void
{
$chunk = new GsspUserAttributesChunk();
$chunk->addAttribute(
'urn:mace:surf.nl:stepup:service-name',
'urn:oasis:names:tc:SAML:2.0:attrname-format:uri',
$serviceName
);
$this->authnRequest->setExtensions([new SAML2Chunk($chunk->getValue())]);
}

#[Then('the service name :serviceName should be stored in state')]
public function assertServiceNameStoredInState(string $serviceName): void
{
$attributes = $this->stateHandler->getGsspUserAttributes();
Assertion::notNull($attributes, 'Expected GsspUserAttributesChunk to be present in state');
Assertion::eq(
$serviceName,
$attributes->getAttributeValue('urn:mace:surf.nl:stepup:service-name'),
sprintf('Expected service name "%s" in state', $serviceName)
);
}

#[Given('set the subject nameId to :nameId')]
public function setTheSubjectNameIdTo(string $nameId): void
{
Expand All @@ -638,4 +668,37 @@ public function theReturnEndpointShouldRaiseAnException($message): void
{
Assertion::eq($message, $this->lastException->getMessage());
}

#[Given('the AuthnRequest contains mdui display name :firstName for language :firstLang and :secondName for language :secondLang')]
public function setMduiDisplayNamesOnAuthnRequest(string $firstName, string $firstLang, string $secondName, string $secondLang): void
{
$chunk = new MduiChunk();
$doc = $chunk->getValue()->ownerDocument;
$ns = 'urn:oasis:names:tc:SAML:metadata:ui';

foreach ([[$firstLang, $firstName], [$secondLang, $secondName]] as [$lang, $name]) {
$el = $doc->createElementNS($ns, 'mdui:DisplayName');
$el->setAttribute('xml:lang', $lang);
$el->textContent = $name;
$chunk->getValue()->appendChild($el);
}

$this->authnRequest->setExtensions([new SAML2Chunk($chunk->getValue())]);
}

#[Then('the mdui display name for language :lang should be :expected in state')]
public function assertMduiDisplayNameInState(string $lang, string $expected): void
{
$mdui = $this->stateHandler->getMdui();
Assertion::notNull($mdui, 'Expected MduiChunk to be present in state');
$names = $mdui->getDisplayNames();
Assertion::keyExists($names, $lang, sprintf('Expected lang "%s" in mdui display names', $lang));
Assertion::eq($expected, $names[$lang], sprintf('Expected display name "%s" for lang "%s"', $expected, $lang));
}

#[Then('no mdui data should be stored in state')]
public function assertNoMduiInState(): void
{
Assertion::false($this->stateHandler->hasMdui(), 'Expected no mdui data in state');
}
}
33 changes: 33 additions & 0 deletions src/Features/authentication.feature
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,36 @@ Feature: When an user needs to be authenticated

When the user is redirected to the identity provider sso return endpoint
Then the return endpoint should raise an exception with "There is no request state present"

# Pre-existing GsspUserAttributes service-name path (urn:mace:surf.nl:stepup:service-name),
# not the mdui:UIInfo mechanism added in this PR. Kept here as regression coverage for the
# saveRequestExtensions() refactor, which now handles both extension types from one call site.
Scenario: Service name from SAML extension is preserved in state during authentication
Given a normal SAML 2.0 AuthnRequest
And the AuthnRequest contains service name 'My University Portal'
And AuthnRequest is signed with sha256
And set the subject nameId to 'unique-identifier-token'

When the service provider sends the AuthnRequest with HTTP-Redirect binding

Then the service name 'My University Portal' should be stored in state

Scenario: mdui:UIInfo display names are preserved in state during authentication
Given a normal SAML 2.0 AuthnRequest
And the AuthnRequest contains mdui display name "Online learning" for language "en" and "Leeromgeving" for language "nl"
And AuthnRequest is signed with sha256
And set the subject nameId to 'unique-identifier-token'

When the service provider sends the AuthnRequest with HTTP-Redirect binding

Then the mdui display name for language "en" should be "Online learning" in state
And the mdui display name for language "nl" should be "Leeromgeving" in state

Scenario: Authentication without mdui:UIInfo does not cause an error
Given a normal SAML 2.0 AuthnRequest
And AuthnRequest is signed with sha256
And set the subject nameId to 'unique-identifier-token'

When the service provider sends the AuthnRequest with HTTP-Redirect binding

Then no mdui data should be stored in state
18 changes: 18 additions & 0 deletions src/Features/registration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ Feature: When an user needs to enroll for a new token
| notice | /Saml response created with id ".+", request ID: ".+"/ | present |
| notice | Invalidate current state and redirect user to service provider assertion consumer url "https://service_provider/saml/acu" | present |

Scenario: mdui:UIInfo display names are preserved in state during registration
Given a normal SAML 2.0 AuthnRequest
And the AuthnRequest contains mdui display name "Online learning" for language "en" and "Leeromgeving" for language "nl"
And AuthnRequest is signed with sha256

When the service provider sends the AuthnRequest with HTTP-Redirect binding

Then the mdui display name for language "en" should be "Online learning" in state
And the mdui display name for language "nl" should be "Leeromgeving" in state

Scenario: Registration without mdui:UIInfo does not cause an error
Given a normal SAML 2.0 AuthnRequest
And AuthnRequest is signed with sha256

When the service provider sends the AuthnRequest with HTTP-Redirect binding

Then no mdui data should be stored in state

Scenario: When an user request the sso return endpoint without being registered the user should be redirected to the application registration endpoint
Given a normal SAML 2.0 AuthnRequest
And AuthnRequest is signed with sha256
Expand Down
5 changes: 5 additions & 0 deletions src/Service/AuthenticationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use SAML2\Constants;
use Surfnet\SamlBundle\SAML2\Extensions\GsspUserAttributesChunk;
use Surfnet\SamlBundle\SAML2\Extensions\MduiChunk;
use Symfony\Component\HttpFoundation\Response;

/**
Expand Down Expand Up @@ -89,4 +90,8 @@ public function getIssuer(): string;
public function getScopingRequesterIds(): array;

public function getGsspUserAttributes(): ?GsspUserAttributesChunk;

public function getMdui(): ?MduiChunk;

public function hasMdui(): bool;
}
5 changes: 5 additions & 0 deletions src/Service/RegistrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace Surfnet\GsspBundle\Service;

use SAML2\Constants;
use Surfnet\SamlBundle\SAML2\Extensions\MduiChunk;
use Symfony\Component\HttpFoundation\Response;

/**
Expand Down Expand Up @@ -62,6 +63,10 @@ public function register(string $subjectNameId): void;
*/
public function isRegistered(): bool;

public function getMdui(): ?MduiChunk;

public function hasMdui(): bool;

public function reject(string $message, string $subCode = Constants::STATUS_AUTHN_FAILED): void;

/*
Expand Down
65 changes: 65 additions & 0 deletions src/Service/ServiceName/ServiceNameResolver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types = 1);

/**
* 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.
*/

namespace Surfnet\GsspBundle\Service\ServiceName;

use Surfnet\SamlBundle\SAML2\Extensions\MduiChunk;
use Surfnet\SamlBundle\SAML2\Extensions\ServiceNameFormatter;

/**
* Mandatory path for reading a service name out of an MduiChunk: this is the only place that
* runs the name through ServiceNameFormatter::format(), which sanitizes it (length cap,
* whitespace collapse, stripping of control/format characters). Calling
* $mdui->getDisplayNames() directly bypasses that sanitization — GSSPs must resolve display
* names through this class, never read MduiChunk's raw names for display.
*/
final class ServiceNameResolver
{
private const FALLBACK_LANGUAGE = 'en';

public static function resolve(?MduiChunk $mdui, string $locale): ?string
{
if ($mdui === null) {
return null;
}
$names = $mdui->getDisplayNames();
if ($names === []) {
return null;
}
$normalizedNames = self::normalizeLanguageKeys($names);
$values = array_values($normalizedNames);
$lang = strtolower(substr($locale, 0, 2));
$raw = $normalizedNames[$lang] ?? $normalizedNames[self::FALLBACK_LANGUAGE] ?? $values[0];
return ServiceNameFormatter::format($raw);
}

/**
* @param array<string, string> $names
* @return array<string, string>
*/
private static function normalizeLanguageKeys(array $names): array
{
$normalized = [];
foreach ($names as $lang => $name) {
$normalized[strtolower(substr($lang, 0, 2))] ??= $name;
}
return $normalized;
}
}
11 changes: 11 additions & 0 deletions src/Service/StateBasedAuthenticationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use SAML2\Constants;
use Surfnet\GsspBundle\Exception\RuntimeException;
use Surfnet\SamlBundle\SAML2\Extensions\GsspUserAttributesChunk;
use Surfnet\SamlBundle\SAML2\Extensions\MduiChunk;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;

Expand Down Expand Up @@ -111,4 +112,14 @@ public function getGsspUserAttributes(): ?GsspUserAttributesChunk
{
return $this->stateHandler->getGsspUserAttributes();
}

public function getMdui(): ?MduiChunk
{
return $this->stateHandler->getMdui();
}

public function hasMdui(): bool
{
return $this->stateHandler->hasMdui();
}
}
11 changes: 11 additions & 0 deletions src/Service/StateBasedRegistrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Psr\Log\LoggerInterface;
use SAML2\Constants;
use Surfnet\GsspBundle\Exception\RuntimeException;
use Surfnet\SamlBundle\SAML2\Extensions\MduiChunk;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;

Expand Down Expand Up @@ -59,6 +60,16 @@ public function isRegistered(): bool
return $this->stateHandler->hasSubjectNameId();
}

public function getMdui(): ?MduiChunk
{
return $this->stateHandler->getMdui();
}

public function hasMdui(): bool
{
return $this->stateHandler->hasMdui();
}

public function registrationRequired(): bool
{
return $this->stateHandler->isRequestTypeRegistration();
Expand Down
Loading
Loading