Allow login to different realms using query param (#188)

This commit is contained in:
Stan Silvert 2020-10-26 04:00:05 -04:00 committed by GitHub
parent 9fb081e3bf
commit 45b878e2e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View file

@ -1,8 +0,0 @@
{
"realm": "master",
"auth-server-url": "http://localhost:8180/auth/",
"ssl-required": "external",
"resource": "security-admin-console-v2",
"public-client": true,
"confidential-port": 0
}

View file

@ -69,7 +69,7 @@ export const RealmSelector = ({ realmList }: RealmSelectorProps) => {
const dropdownItems = realmList.map((r) => ( const dropdownItems = realmList.map((r) => (
<DropdownItem <DropdownItem
key={r.id} key={`realm-dropdown-item-${r.realm}`}
onClick={() => { onClick={() => {
setRealm(r.realm); setRealm(r.realm);
setOpen(!open); setOpen(!open);

View file

@ -1,5 +1,13 @@
import Keycloak, { KeycloakInstance } from "keycloak-js"; import Keycloak, { KeycloakInstance } from "keycloak-js";
const keycloak: KeycloakInstance = Keycloak("/keycloak.json");
const realm =
new URLSearchParams(window.location.search).get("realm") || "master";
const keycloak: KeycloakInstance = Keycloak({
url: "http://localhost:8180/auth/",
realm: realm,
clientId: "security-admin-console-v2",
});
export default async function (): Promise<KeycloakInstance> { export default async function (): Promise<KeycloakInstance> {
await keycloak.init({ onLoad: "check-sso", pkceMethod: "S256" }).catch(() => { await keycloak.init({ onLoad: "check-sso", pkceMethod: "S256" }).catch(() => {