-
Notifications
You must be signed in to change notification settings - Fork 87
Description
Hey, we love the library so far. However, we ran into an issue where we need to change authority based on which route user arrived to our page from.
Examples against Keycloak:
/login/realm1 -> authority needs to be
${window.ENV.oidcEndpoint}/auth/realms/${localStorageRealm}
/login/realm2 -> authority needs to be
${window.ENV.oidcEndpoint}/auth/realms/${window.ENV.defaultRealm}
Same thing with post_logout_redirect_uri:
If realm1: post_logout_redirect_uri:
${window.ENV.oidcEndpoint}/login/${localStorageRealm}
If realm2: post_logout_redirect_uri:
${window.ENV.oidcEndpoint}/login/${window.ENV.defaultRealm}
The problem is that our Login page is a child of the component that initializes
<AuthProvider {...oidcConfig}/>
We have already tried:
const [authority, setAuthority] = useState(`${window.ENV.oidcEndpoint}/auth/realms/${window.ENV.defaultRealm}`);
useEffect(() => {
if (localStorageRealm) {
setAuthority(`${window.ENV.oidcEndpoint}/auth/realms/${localStorageRealm}`)
}
}, [localStorageRealm]);
...
return (
<AuthProvider onSigninCallback={resetHistoryState} {...oidcConfig} authority={authority} >
<App/>
</AuthProvider>
);
However this has not worked so far, because authority does not update, it stays the initial value. We know how to do this with oidc-client-ts, where we would instantiate new UserManager for each time we want to change OidcClientSettings, but was wondering if it is possible to do it with react-oidc-context?
Thank you for any ideas.