Skip to content

Commit

Permalink
Support kcHttpRelativePath queryParam option
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Aug 18, 2024
1 parent fd47750 commit eb119c4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/oidc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,22 @@ export const { OidcProvider, useOidc } = (() => {

}

const host = `http://localhost:${(new URLSearchParams(window.location.search)).get("port") ?? "8080"}`;
const realm = new URLSearchParams(window.location.search).get("realm") ?? "myrealm";

const issuerUri = (() => {

const port = (new URLSearchParams(window.location.search)).get("port") ?? "8080";
const kcHttpRelativePath = (new URLSearchParams(window.location.search)).get("kcHttpRelativePath") ?? "";

return `http://localhost:${port}${kcHttpRelativePath}/realms/${realm}`;

})();

const clientId = new URLSearchParams(window.location.search).get("client") ?? "myclient";
keycloakAccountUrl = `${host}/realms/${realm}/account?referrer=${clientId}&referrer_uri=${window.location.origin}`;
keycloakAccountUrl = `${issuerUri}/account?referrer=${clientId}&referrer_uri=${window.location.origin}`;

return createReactOidc({
issuerUri: `${host}/realms/${realm}`,
issuerUri,
clientId,
publicUrl,
isAuthGloballyRequired,
Expand Down

0 comments on commit eb119c4

Please sign in to comment.