Skip to content

Commit

Permalink
fix(auth): fix sso - test new usermanager
Browse files Browse the repository at this point in the history
  • Loading branch information
lailabjil committed Jan 30, 2024
1 parent 55d3409 commit fbac014
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const getAuthority = () => {
return authority;
};

const userManagerCustom = isSSO ? { userManager: createUserManager() } : {};
const oidcConfigSSO = {
userManager: createUserManager(),
};

const oidcConfig = {
onSignIn: () => {
Expand All @@ -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(
<AuthProvider {...oidcConfig}>
<AuthProvider {...oidcProps}>
<React.StrictMode>
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
Expand Down
9 changes: 7 additions & 2 deletions src/service/auth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
Expand Down Expand Up @@ -81,6 +82,10 @@ const createUserManager = () => {
signinSilent(userManager);
});

userManager.metadataService.getMetadata().then(data => {
console.log("metadata of new userManager");
});

return userManager;
};

Expand Down

0 comments on commit fbac014

Please sign in to comment.