-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
redirect_uri in app #452
Comments
Hello @d-sooter,
I assume that what you are trying to acheive is to get the refferer_uri so that when users click on the header they get redirected to the app that redirected the user to Keycloak. Unfortunately Keycloak does define a way do do that. But I can show you how we do it: It's a bit hacky, we remove the Without using any third party lib it should look something like: function getRefererUrlFromUrl() {
const queryParams = new URLSearchParams(window.location.search);
const redirectUri = queryParams.get('redirect_uri');
if (redirectUri === null) {
return undefined;
}
const redirectUrl = new URL(redirectUri);
return redirectUrl.origin;
}
const localStorageKey = 'theme-onyxia_refererUrl';
export function getReferrerUrl() {
const refererUrl = getRefererUrlFromUrl();
if (refererUrl === undefined) {
return localStorage.getItem(localStorageKey) ?? undefined;
}
localStorage.setItem(localStorageKey, refererUrl);
return refererUrl;
} Be aware that the Hope it helps |
Thanks a lot i will try that out. My use case is actually a lot simpler. We have a multi-tenant thing going on but all happening in one realm. We have a custom theme, but allow custom background images or logos to be set per tenant. then i use the subdomain in the redirect url to detect which tenant the request is coming from and load the proper logo an picture. Or is there another way to pass a custom query param or header to the request and pick it up in keycloakify? We are only interested in the login page. |
Ok I see, For that usecase in perticualr we have the theme variant feature that you might want to consider. https://docs.keycloakify.dev/build-options#extrathemenames You can select the theme at the Keycloak client configuration level in Keycloak. To load different global css file based on the theme name you can implement this strategy: // src/keycloak-theme/login/useGlobalStylesheet.ts
export function useGlobalStylesheet(themeName: string){
useState(() => {
switch(themeName){
case "keycloakify-starter":
// @ts-expect-error
import("./keycloakify-starter.css");
break;
case "keycloakify-starter-variant-1":
// @ts-expect-error
import("./keycloakify-starter-variant-1.css");
break;
}
});
} // src/keycloak-theme/login/KcApp.tsx
import { useGlobalStylesheet } from "./useGlobalStylesheet";
// ...
export default function KcApp(props: { kcContext: KcContext; }) {
const { kcContext }= props;
// ...
useGlogalStylesheet(kcContext.themeName);
// ... |
Hi Guys first of all great tool
I am trying to get the full url or at least the redirect_uri in the login page ( in react) is there any way to do that? i tried different things but wasnt able to find it.
thank in advance
The text was updated successfully, but these errors were encountered: