Skip to content

Commit 180aba8

Browse files
committed
autofill username when it's hinted by the SP in a request parameter (MS Entra ID)
1 parent 4f1582b commit 180aba8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

modules/saml/src/IdP/SAML2.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ public static function receiveAuthnRequest(Request $request, IdP $idp): Response
345345
}
346346

347347
$authnRequestSigned = false;
348+
$username = null;
348349

349350
if ($request->query->has('spentityid') || $request->query->has('providerId')) {
350351
/* IdP initiated authentication. */
@@ -418,6 +419,8 @@ public static function receiveAuthnRequest(Request $request, IdP $idp): Response
418419
);
419420
}
420421

422+
$username = $request->get('username', null);
423+
421424
$issuer = $request->getIssuer();
422425
if ($issuer === null) {
423426
throw new Error\BadRequest(
@@ -529,6 +532,7 @@ public static function receiveAuthnRequest(Request $request, IdP $idp): Response
529532
Auth\State::RESTART => $sessionLostURL,
530533

531534
'SPMetadata' => $spMetadata->toArray(),
535+
'core:username' => $username,
532536
'saml:RelayState' => $relayState,
533537
'saml:RequestId' => $requestId,
534538
'saml:IDPList' => $IDPList,

tests/modules/saml/src/IdP/SAML2Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class SAML2Test extends ClearStateTestCase
4848
'saml:NameIDFormat' => null,
4949
'saml:AllowCreate' => true,
5050
'saml:Extensions' => null,
51-
'saml:RequestedAuthnContext' => null
51+
'saml:RequestedAuthnContext' => null,
52+
'core:username' => null,
5253
];
5354

5455

0 commit comments

Comments
 (0)