Use correct environment variables in Account Console v3 (#19934)
This commit is contained in:
parent
e21fc968e2
commit
48354a1bb8
7 changed files with 19 additions and 30 deletions
|
@ -77,10 +77,10 @@
|
|||
<![CDATA[
|
||||
<script id="environment" type="application/json">
|
||||
{
|
||||
"loginRealm": "${loginRealm!"master"}",
|
||||
"authServerUrl": "${authUrl}",
|
||||
"resourceUrl": "${resourceUrl}",
|
||||
"isRunningAsTheme": true
|
||||
"authUrl": "${authUrl}",
|
||||
"isRunningAsTheme": true,
|
||||
"realm": "${realm.name}",
|
||||
"resourceUrl": "${resourceUrl}"
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -67,9 +67,9 @@ function checkResponse<T>(response: T) {
|
|||
|
||||
async function get(path: string, params: RequestInit): Promise<Response> {
|
||||
const url = joinPath(
|
||||
environment.authServerUrl,
|
||||
environment.authUrl,
|
||||
"realms",
|
||||
environment.loginRealm,
|
||||
environment.realm,
|
||||
"account",
|
||||
path
|
||||
);
|
||||
|
|
|
@ -103,12 +103,7 @@ export async function unLinkAccount(account: LinkedAccountRepresentation) {
|
|||
|
||||
export async function linkAccount(account: LinkedAccountRepresentation) {
|
||||
const redirectUri = encodeURIComponent(
|
||||
joinPath(
|
||||
environment.authServerUrl,
|
||||
"realms",
|
||||
environment.loginRealm,
|
||||
"account"
|
||||
)
|
||||
joinPath(environment.authUrl, "realms", environment.realm, "account")
|
||||
);
|
||||
const response = await request("/linked-accounts/" + account.providerName, {
|
||||
searchParams: { providerId: account.providerName, redirectUri },
|
||||
|
|
|
@ -15,13 +15,7 @@ export async function request(
|
|||
{ signal, method, searchParams, body }: RequestOptions = {}
|
||||
): Promise<Response> {
|
||||
const url = new URL(
|
||||
joinPath(
|
||||
environment.authServerUrl,
|
||||
"realms",
|
||||
environment.loginRealm,
|
||||
"account",
|
||||
path
|
||||
)
|
||||
joinPath(environment.authUrl, "realms", environment.realm, "account", path)
|
||||
);
|
||||
|
||||
if (searchParams) {
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
export type Environment = {
|
||||
/** The realm which should be used when signing into the application. */
|
||||
loginRealm: string;
|
||||
/** The URL to the root of the auth server. */
|
||||
authServerUrl: string;
|
||||
/** The URL to resources such as the files in the `public` directory. */
|
||||
resourceUrl: string;
|
||||
authUrl: string;
|
||||
/** Indicates if the application is running as a Keycloak theme. */
|
||||
isRunningAsTheme: boolean;
|
||||
/** The realm used to sign into. */
|
||||
realm: string;
|
||||
/** The URL to resources such as the files in the `public` directory. */
|
||||
resourceUrl: string;
|
||||
};
|
||||
|
||||
// The default environment, used during development.
|
||||
const defaultEnvironment: Environment = {
|
||||
loginRealm: "master",
|
||||
authServerUrl: "http://localhost:8180",
|
||||
resourceUrl: "http://localhost:8080",
|
||||
authUrl: "http://localhost:8180",
|
||||
isRunningAsTheme: false,
|
||||
realm: "master",
|
||||
resourceUrl: "http://localhost:8080",
|
||||
};
|
||||
|
||||
// Merge the default and injected environment variables together.
|
||||
|
|
|
@ -2,8 +2,8 @@ import Keycloak from "keycloak-js";
|
|||
import { environment } from "./environment";
|
||||
|
||||
export const keycloak = new Keycloak({
|
||||
url: environment.authServerUrl,
|
||||
realm: environment.loginRealm,
|
||||
url: environment.authUrl,
|
||||
realm: environment.realm,
|
||||
clientId: environment.isRunningAsTheme
|
||||
? "account-console"
|
||||
: "security-admin-console-v2",
|
||||
|
|
|
@ -26,7 +26,7 @@ async function startServer() {
|
|||
[
|
||||
"start-dev",
|
||||
"--http-port=8180",
|
||||
"--features=admin2,admin-fine-grained-authz,declarative-user-profile",
|
||||
"--features=account3,admin-fine-grained-authz,declarative-user-profile",
|
||||
...args,
|
||||
],
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue