diff --git a/src/auth/ChromeAuthContext.ts b/src/auth/ChromeAuthContext.ts index 37bb8092d..b97d46a70 100644 --- a/src/auth/ChromeAuthContext.ts +++ b/src/auth/ChromeAuthContext.ts @@ -4,6 +4,7 @@ import { createContext } from 'react'; import { OfflineTokenResponse } from './offline'; export type ChromeAuthContextValue = { + ssoUrl: string; ready: boolean; user: ChromeUser; getUser: () => Promise; @@ -30,6 +31,7 @@ const blankUser: ChromeUser = { }; const ChromeAuthContext = createContext({ + ssoUrl: '', ready: false, logoutAllTabs: () => undefined, loginAllTabs: () => undefined, diff --git a/src/auth/OIDCConnector/OIDCProvider.tsx b/src/auth/OIDCConnector/OIDCProvider.tsx index d91ad0076..d82c10376 100644 --- a/src/auth/OIDCConnector/OIDCProvider.tsx +++ b/src/auth/OIDCConnector/OIDCProvider.tsx @@ -74,7 +74,12 @@ const OIDCProvider: React.FC = ({ children }) => { return ( - + {children} diff --git a/src/auth/OIDCConnector/OIDCSecured.tsx b/src/auth/OIDCConnector/OIDCSecured.tsx index ef51f5fca..fb047fe6d 100644 --- a/src/auth/OIDCConnector/OIDCSecured.tsx +++ b/src/auth/OIDCConnector/OIDCSecured.tsx @@ -80,7 +80,8 @@ export function OIDCSecured({ microFrontendConfig, cookieElement, setCookieElement, -}: React.PropsWithChildren<{ microFrontendConfig: Record } & FooterProps>) { + ssoUrl, +}: React.PropsWithChildren<{ microFrontendConfig: Record; ssoUrl: string } & FooterProps>) { const auth = useAuth(); const authRef = useRef(auth); const store = useStore(); @@ -91,6 +92,7 @@ export function OIDCSecured({ const activeModule = useAtomValue(activeModuleDefinitionReadAtom); const requiredScopes = activeModule?.config?.ssoScopes || []; const [state, setState] = useState({ + ssoUrl, ready: false, logoutAllTabs: (bounce = true) => { authChannel.postMessage({ type: 'logout' }); diff --git a/src/chrome/create-chrome.test.ts b/src/chrome/create-chrome.test.ts index ab5d0fa8c..64dabbba8 100644 --- a/src/chrome/create-chrome.test.ts +++ b/src/chrome/create-chrome.test.ts @@ -40,6 +40,7 @@ const mockUser: ChromeUser = { describe('create chrome', () => { const chromeAuthMock: ChromeAuthContextValue = { + ssoUrl: '', doOffline() { return Promise.resolve(); }, diff --git a/src/chrome/create-chrome.ts b/src/chrome/create-chrome.ts index 4a49379e8..c8dfd4713 100644 --- a/src/chrome/create-chrome.ts +++ b/src/chrome/create-chrome.ts @@ -118,7 +118,19 @@ export const createChromeContext = ({ getBundleData: useBundle, getApp: () => getUrl('app'), getEnvironment: () => getEnv(), - getEnvironmentDetails: () => getEnvDetails(), + getEnvironmentDetails: () => { + let environment = getEnvDetails(); + if (environment && chromeAuth.ssoUrl) { + environment.sso = chromeAuth.ssoUrl; + } else { + environment = { + url: [], + portal: 'undefined', + sso: chromeAuth.ssoUrl, + }; + } + return environment; + }, createCase: (fields?: any) => chromeAuth.getUser().then((user) => createSupportCase(user!.identity, chromeAuth.token, fields)), getUserPermissions: async (app = '', bypassCache?: boolean) => { const token = await chromeAuth.getToken();