chore(ui): Replace ssoSilent with acquireTokenSilent for token renewal#27116
chore(ui): Replace ssoSilent with acquireTokenSilent for token renewal#27116chirag-madlani merged 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Azure MSAL authenticator flow in the UI to use acquireTokenSilent (cache/refresh-token based) instead of ssoSilent (iframe/cookie based) for silent token acquisition, aiming to reduce interaction_required failures under modern browser privacy restrictions.
Changes:
- Switched MSAL silent token call from
ssoSilenttoacquireTokenSilentinMsalAuthenticator. - Small hardening/cleanup in token refresh utilities (use
globalThis, optional chaining, remove console timing). - Added an
aria-labelto the popup settings link.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| openmetadata-ui/src/main/resources/ui/src/utils/Auth/TokenService/TokenServiceUtil.ts | Minor browser-global cleanup (globalThis) and callback invocation cleanup for token refresh notifications. |
| openmetadata-ui/src/main/resources/ui/src/components/Auth/AppAuthenticators/MsalAuthenticator.tsx | Replaces silent auth method with acquireTokenSilent and updates a link’s accessibility label. |
Comments suppressed due to low confidence (1)
openmetadata-ui/src/main/resources/ui/src/components/Auth/AppAuthenticators/MsalAuthenticator.tsx:98
renewIdToken()callsfetchIdToken()with the defaultshouldFallbackToPopup=false, so whenacquireTokenSilentthrowsInteractionRequiredAuthError(the scenario this PR is addressing), the code currently falls into the non-fallback branch and just rethrows. This means token renewal can still hard-fail instead of triggering an interactive flow. Consider handlingInteractionRequiredAuthErrorunconditionally here (e.g., initiateloginRedirectin top-level windows andloginPopupwhen embedded) or pass/deriveshouldFallbackToPopupso the fallback path is actually reachable.
const tokenRequest = {
account: account || accounts[0], // This is an example - Select account based on your app's requirements
scopes: msalLoginRequest.scopes,
};
try {
const response = await instance.acquireTokenSilent(tokenRequest);
const msalResponse = await parseMSALResponse(response);
return msalResponse;
} catch (error) {
if (
error instanceof InteractionRequiredAuthError &&
shouldFallbackToPopup
) {
| try { | ||
| const response = await instance.ssoSilent(tokenRequest); | ||
| const response = await instance.acquireTokenSilent(tokenRequest); | ||
| const msalResponse = await parseMSALResponse(response); | ||
|
|
There was a problem hiding this comment.
This code path switched from ssoSilent to acquireTokenSilent, but there is an existing unit test (MsalAuthenticator.test.tsx) that still mocks/asserts ssoSilent for renewIdToken. The test suite will fail unless the mock instance and assertions are updated to use acquireTokenSilent and to reflect any new interaction-required fallback behavior.
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Fixed in d470b3f. Updated MsalAuthenticator.test.tsx to:
- Replace
ssoSilentwithacquireTokenSilentin the mock instance - Update the
renewIdTokensuccess test to assert againstacquireTokenSilent - Add a new test that verifies
InteractionRequiredAuthErroris propagated whenrenewIdTokenencounters an expired/interaction-required session (aligning with the new fallback behavior)
Agent-Logs-Url: https://github.com/open-metadata/OpenMetadata/sessions/4944b541-e32a-4904-9ac9-d1dc62acb565 Co-authored-by: chirag-madlani <12962843+chirag-madlani@users.noreply.github.com>
Code Review ✅ ApprovedReplaces the deprecated ssoSilent method with acquireTokenSilent for Azure token renewal, including corresponding test updates. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
🟡 Playwright Results — all passed (21 flaky)✅ 3597 passed · ❌ 0 failed · 🟡 21 flaky · ⏭️ 207 skipped
🟡 21 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
|
Failed to cherry-pick changes to the 1.12.5 branch. |
#27116) * chore(ui): Replace ssoSilent with acquireTokenSilent for token renewal * fix(ui): update MsalAuthenticator tests to use acquireTokenSilent Agent-Logs-Url: https://github.com/open-metadata/OpenMetadata/sessions/4944b541-e32a-4904-9ac9-d1dc62acb565 Co-authored-by: chirag-madlani <12962843+chirag-madlani@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> (cherry picked from commit 65effdb)
#27116) * chore(ui): Replace ssoSilent with acquireTokenSilent for token renewal * fix(ui): update MsalAuthenticator tests to use acquireTokenSilent Agent-Logs-Url: https://github.com/open-metadata/OpenMetadata/sessions/4944b541-e32a-4904-9ac9-d1dc62acb565 Co-authored-by: chirag-madlani <12962843+chirag-madlani@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> (cherry picked from commit 65effdb)
open-metadata#27116) * chore(ui): Replace ssoSilent with acquireTokenSilent for token renewal * fix(ui): update MsalAuthenticator tests to use acquireTokenSilent Agent-Logs-Url: https://github.com/open-metadata/OpenMetadata/sessions/4944b541-e32a-4904-9ac9-d1dc62acb565 Co-authored-by: chirag-madlani <12962843+chirag-madlani@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
open-metadata#27116) * chore(ui): Replace ssoSilent with acquireTokenSilent for token renewal * fix(ui): update MsalAuthenticator tests to use acquireTokenSilent Agent-Logs-Url: https://github.com/open-metadata/OpenMetadata/sessions/4944b541-e32a-4904-9ac9-d1dc62acb565 Co-authored-by: chirag-madlani <12962843+chirag-madlani@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>



Describe your changes:
This PR replaces usage of
ssoSilentwithacquireTokenSilentfor silent token acquisition. The change addresses consistentinteraction_required (AADSTS160021)failures observed due to browser restrictions impacting iframe-based authentication flows.Background / Problem
We were relying on
ssoSilentfor session renewal. This method depends on:prompt=noneModern browser privacy changes (third-party cookie restrictions) prevent access to Azure AD session cookies in iframe contexts. As a result:
ssoSilentfails consistently withinteraction_requiredThis behavior is platform-driven (browser + Microsoft Entra ID), not due to application logic changes.
Solution
Switch to
acquireTokenSilentas the primary mechanism for token acquisition.Fallback handling:
InteractionRequiredAuthError, triggerloginRedirect(top-level if in iframe)Changes
Replaced:
with:
Updated error handling:
ssoSilentfailureEnsured:
getAllAccounts()Updated
MsalAuthenticator.test.tsx:ssoSilentmock withacquireTokenSilentin the mock instancerenewIdTokensuccess test assertions to useacquireTokenSilentInteractionRequiredAuthErroris propagated whenrenewIdTokenencounters an expired/interaction-required sessionImpact
✅ Eliminates false logout scenarios
⚠️ First-time login or expired sessions may require redirect (expected behavior)
✅ Improves reliability of token renewal
✅ Aligns with modern browser security model
✅ Unit tests now accurately reflect the
acquireTokenSilent-based flowTesting
acquireTokenSilentNotes
ssoSilentis inherently unreliable in modern browsers due to third-party cookie restrictions. This change aligns with recommended SPA authentication patterns from Microsoft Entra ID.Type of change:
Checklist:
Fixes <issue-number>: <short explanation>