From fbac01411d5152dd6d4316208c6b160116c47a5c Mon Sep 17 00:00:00 2001 From: Laila Abjil Date: Tue, 30 Jan 2024 15:56:35 +0100 Subject: [PATCH] fix(auth): fix sso - test new usermanager --- src/index.tsx | 9 ++++++--- src/service/auth-service.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index d22129a9..bb25ba46 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -19,7 +19,9 @@ const getAuthority = () => { return authority; }; -const userManagerCustom = isSSO ? { userManager: createUserManager() } : {}; +const oidcConfigSSO = { + userManager: createUserManager(), +}; const oidcConfig = { onSignIn: () => { @@ -29,11 +31,12 @@ const oidcConfig = { authority: getAuthority(), clientId: process.env.REACT_APP_KEYCLOAK_CLIENT_ID, redirectUri: process.env.REACT_APP_KEYCLOAK_REDIRECT_URI, - ...{ userManagerCustom }, }; +const oidcProps = isSSO ? Object.assign(oidcConfig, oidcConfigSSO) : oidcConfig; + root.render( - + diff --git a/src/service/auth-service.ts b/src/service/auth-service.ts index 9859ca90..2407db4c 100644 --- a/src/service/auth-service.ts +++ b/src/service/auth-service.ts @@ -12,6 +12,7 @@ const isSSO = attributeSSO && window.location.search.includes(attributeSSO); const url = isSSO ? authUrlSS0 : authUrl; const createUserManager = () => { + console.log("create new usermanager"); const IDENTITY_CONFIG = { authority: url, //(string): The URL of the OIDC provider. client_id: clientId, //(string): Your client application's identifier as registered with the OIDC provider. @@ -21,12 +22,12 @@ const createUserManager = () => { const METADATA_OIDC = { issuer: url, authorization_endpoint: url + protocol + "?" + attributeSSO, - token_endpoint: url + protocol + "/token", + token_endpoint: url + "protocol/openid-connect/token", introspection_endpoint: url + protocol + "/introspect", userinfo_endpoint: url + protocol + "/userInfo", end_session_endpoint: url + protocol + "/logout", revocation_endpoint: url + protocol + "/revoke", - registration_endpoint: url + "/clients-registrations/openid-connect", + registration_endpoint: url + "clients-registrations/openid-connect", jwks_uri: url + "/.well-known/openid-configuration/?" + attributeSSO, device_authorization_endpoint: url + protocol + "/device", backchannel_authentication_endpoint: url + protocol + "/ext/ciba/auth", @@ -81,6 +82,10 @@ const createUserManager = () => { signinSilent(userManager); }); + userManager.metadataService.getMetadata().then(data => { + console.log("metadata of new userManager"); + }); + return userManager; };