Skip to content

Commit a8e62f6

Browse files
authored
Merge pull request #213 from OpenConext/add-azure-domain-hint
Add azure/entra domain hint using "whr" query parameter
2 parents f65e3e8 + 1e0268b commit a8e62f6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/Surfnet/AzureMfa/Application/Service/AzureMfaService.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,17 @@ public function createAuthnRequest(User $user, bool $forceAuthn = false): string
159159
// Create redirect response.
160160
$query = $authnRequest->buildRequestQuery();
161161

162+
// For Azure, add a "whr" query parameter with the domain of the user we want to authenticate.
163+
if ($azureMfaIdentityProvider->isAzureAD()) {
164+
// EntraID does not accept a Subject like ADFS does, and there is no other way to pass the full user ID.
165+
// The Windows home realm hint (whr) parameter can help bypass the Microsoft Account Picker
166+
// (Home Realm Discovery) when the user has multiple accounts, thereby improving the user (SSO) experience.
167+
168+
// Get domain part of the user's email address (UPN) and use that as home realm
169+
$domain = $user->getEmailAddress()->getDomain();
170+
$query .= '&whr=' . urlencode($domain);
171+
}
172+
162173
return sprintf(
163174
'%s?%s',
164175
$destination->getUrl(),

0 commit comments

Comments
 (0)