2020-11-12 12:55:52 +00:00
|
|
|
import KcAdminClient from "keycloak-admin";
|
2020-10-26 08:00:05 +00:00
|
|
|
|
2020-11-12 12:55:52 +00:00
|
|
|
export default async function (): Promise<KcAdminClient> {
|
|
|
|
const realm =
|
|
|
|
new URLSearchParams(window.location.search).get("realm") || "master";
|
2020-10-26 08:00:05 +00:00
|
|
|
|
2020-11-12 12:55:52 +00:00
|
|
|
const kcAdminClient = new KcAdminClient();
|
2020-08-04 12:59:41 +00:00
|
|
|
|
2020-11-12 12:55:52 +00:00
|
|
|
try {
|
|
|
|
await kcAdminClient.init(
|
|
|
|
{ onLoad: "check-sso", pkceMethod: "S256" },
|
|
|
|
{
|
|
|
|
url: "http://localhost:8180/auth/",
|
|
|
|
realm: realm,
|
|
|
|
clientId: "security-admin-console-v2",
|
|
|
|
}
|
|
|
|
);
|
|
|
|
kcAdminClient.baseUrl = "";
|
|
|
|
} catch (error) {
|
2020-09-01 14:51:59 +00:00
|
|
|
alert("failed to initialize keycloak");
|
2020-11-12 12:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return kcAdminClient;
|
2020-08-04 12:59:41 +00:00
|
|
|
}
|