Skip to content

Commit 4072bf8

Browse files
Revert "Fix Azure AD SSO logout to terminate IdP session (#26327)" (#27055)
This reverts commit 765f854. (cherry picked from commit c471dfc)
1 parent e82e23a commit 4072bf8

3 files changed

Lines changed: 10 additions & 39 deletions

File tree

openmetadata-ui/src/main/resources/ui/src/components/Auth/AppAuthenticators/MsalAuthenticator.test.tsx

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jest.mock('../../../utils/AuthProvider.util', () => ({
3636
const mockInstance = {
3737
loginPopup: jest.fn(),
3838
loginRedirect: jest.fn(),
39-
logoutRedirect: jest.fn(),
4039
handleRedirectPromise: jest.fn(),
4140
ssoSilent: jest.fn(),
4241
logout: jest.fn(),
@@ -126,33 +125,7 @@ describe('MsalAuthenticator', () => {
126125
expect(mockInstance.loginRedirect).toHaveBeenCalledWith(msalLoginRequest);
127126
});
128127

129-
it('should handle logout by calling logoutRedirect to terminate IdP session', async () => {
130-
mockInstance.logoutRedirect.mockResolvedValueOnce(undefined);
131-
132-
render(
133-
<MsalAuthenticator
134-
{...mockProps}
135-
ref={(ref) => (authenticatorRef = ref)}
136-
/>
137-
);
138-
139-
await act(async () => {
140-
authenticatorRef?.invokeLogout();
141-
});
142-
143-
expect(mockHandleSuccessfulLogout).toHaveBeenCalled();
144-
expect(mockInstance.logoutRedirect).toHaveBeenCalledWith(
145-
expect.objectContaining({
146-
postLogoutRedirectUri: expect.stringContaining('/signin'),
147-
})
148-
);
149-
});
150-
151-
it('should fallback to local cleanup when logoutRedirect fails', async () => {
152-
mockInstance.logoutRedirect.mockRejectedValueOnce(
153-
new Error('logout failed')
154-
);
155-
128+
it('should handle logout', async () => {
156129
render(
157130
<MsalAuthenticator
158131
{...mockProps}
@@ -164,7 +137,6 @@ describe('MsalAuthenticator', () => {
164137
authenticatorRef?.invokeLogout();
165138
});
166139

167-
expect(mockInstance.logoutRedirect).toHaveBeenCalled();
168140
expect(mockHandleSuccessfulLogout).toHaveBeenCalled();
169141
});
170142

openmetadata-ui/src/main/resources/ui/src/components/Auth/AppAuthenticators/MsalAuthenticator.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
useEffect,
2424
useImperativeHandle,
2525
} from 'react';
26-
import { ROUTES } from '../../../constants/constants';
2726
import {
2827
msalLoginRequest,
2928
parseMSALResponse,
@@ -50,7 +49,7 @@ const MsalAuthenticator = forwardRef<AuthenticatorRef, Props>(
5049

5150
const login = async () => {
5251
try {
53-
const isInIframe = globalThis.self !== window.top;
52+
const isInIframe = window.self !== window.top;
5453

5554
if (isInIframe) {
5655
// Use popup login when in iframe to avoid redirect issues
@@ -69,14 +68,14 @@ const MsalAuthenticator = forwardRef<AuthenticatorRef, Props>(
6968

7069
const logout = async () => {
7170
try {
71+
for (const key in localStorage) {
72+
if (key.includes('-login.windows.net-') || key.startsWith('msal.')) {
73+
localStorage.removeItem(key);
74+
}
75+
}
76+
} finally {
77+
// Cleanup application state
7278
handleSuccessfulLogout();
73-
await instance.logoutRedirect({
74-
account: account ?? accounts[0],
75-
logoutHint: (account ?? accounts[0])?.username,
76-
postLogoutRedirectUri: globalThis.location.origin + ROUTES.SIGNIN,
77-
});
78-
} catch {
79-
// logoutRedirect failed; app state already cleaned up above
8079
}
8180
};
8281

openmetadata-ui/src/main/resources/ui/src/utils/AuthProvider.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export const getAuthConfig = (
204204
authority,
205205
clientId,
206206
redirectUri,
207-
postLogoutRedirectUri: globalThis.location.origin + ROUTES.SIGNIN,
207+
postLogoutRedirectUri: '/',
208208
},
209209
cache: {
210210
cacheLocation: BrowserCacheLocation.LocalStorage,

0 commit comments

Comments
 (0)