This commit is contained in:
parent
6d667f653e
commit
ffefb38161
@ -26,6 +26,7 @@ export namespace BuildOptions {
|
|||||||
appInputPath: string;
|
appInputPath: string;
|
||||||
// Directory that keycloakify outputs to. Defaults to {cwd}/build_keycloak
|
// Directory that keycloakify outputs to. Defaults to {cwd}/build_keycloak
|
||||||
keycloakBuildPath: string;
|
keycloakBuildPath: string;
|
||||||
|
customUserAttributes: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Standalone = Common & {
|
export type Standalone = Common & {
|
||||||
@ -133,7 +134,8 @@ export function readBuildOptions(params: { CNAME: string | undefined; isExternal
|
|||||||
isSilent,
|
isSilent,
|
||||||
"keycloakVersionDefaultAssets": keycloakVersionDefaultAssets ?? "11.0.3",
|
"keycloakVersionDefaultAssets": keycloakVersionDefaultAssets ?? "11.0.3",
|
||||||
appInputPath: getAppInputPath(),
|
appInputPath: getAppInputPath(),
|
||||||
keycloakBuildPath: getKeycloakBuildPath()
|
keycloakBuildPath: getKeycloakBuildPath(),
|
||||||
|
"customUserAttributes": keycloakify.customUserAttributes ?? []
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
"totp", "totpSecret", "SAMLRequest", "SAMLResponse", "relayState", "device_user_code", "code",
|
"totp", "totpSecret", "SAMLRequest", "SAMLResponse", "relayState", "device_user_code", "code",
|
||||||
"password-new", "rememberMe", "login", "authenticationExecution", "cancel-aia", "clientDataJSON",
|
"password-new", "rememberMe", "login", "authenticationExecution", "cancel-aia", "clientDataJSON",
|
||||||
"authenticatorData", "signature", "credentialId", "userHandle", "error", "authn_use_chk", "authenticationExecution",
|
"authenticatorData", "signature", "credentialId", "userHandle", "error", "authn_use_chk", "authenticationExecution",
|
||||||
"isSetRetry", "try-again", "attestationObject", "publicKeyCredentialId", "authenticatorLabel",
|
"isSetRetry", "try-again", "attestationObject", "publicKeyCredentialId", "authenticatorLabel"CUSTOM_USER_ATTRIBUTES_eKsIY4ZsZ4xeM
|
||||||
"location", "occupation"
|
|
||||||
]>
|
]>
|
||||||
|
|
||||||
<#attempt>
|
<#attempt>
|
||||||
|
@ -8,7 +8,6 @@ import { objectKeys } from "tsafe/objectKeys";
|
|||||||
import { ftlValuesGlobalName } from "../ftlValuesGlobalName";
|
import { ftlValuesGlobalName } from "../ftlValuesGlobalName";
|
||||||
import type { BuildOptions } from "../BuildOptions";
|
import type { BuildOptions } from "../BuildOptions";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import { Reflect } from "tsafe/Reflect";
|
|
||||||
|
|
||||||
export const themeTypes = ["login", "account"] as const;
|
export const themeTypes = ["login", "account"] as const;
|
||||||
|
|
||||||
@ -47,7 +46,11 @@ export type AccountThemePageId = (typeof accountThemePageIds)[number];
|
|||||||
export type BuildOptionsLike = BuildOptionsLike.Standalone | BuildOptionsLike.ExternalAssets;
|
export type BuildOptionsLike = BuildOptionsLike.Standalone | BuildOptionsLike.ExternalAssets;
|
||||||
|
|
||||||
export namespace BuildOptionsLike {
|
export namespace BuildOptionsLike {
|
||||||
export type Standalone = {
|
export type Common = {
|
||||||
|
customUserAttributes: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Standalone = Common & {
|
||||||
isStandalone: true;
|
isStandalone: true;
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
};
|
};
|
||||||
@ -59,11 +62,13 @@ export namespace BuildOptionsLike {
|
|||||||
isStandalone: false;
|
isStandalone: false;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SameDomain = CommonExternalAssets & {
|
export type SameDomain = Common &
|
||||||
|
CommonExternalAssets & {
|
||||||
areAppAndKeycloakServerSharingSameDomain: true;
|
areAppAndKeycloakServerSharingSameDomain: true;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DifferentDomains = CommonExternalAssets & {
|
export type DifferentDomains = Common &
|
||||||
|
CommonExternalAssets & {
|
||||||
areAppAndKeycloakServerSharingSameDomain: false;
|
areAppAndKeycloakServerSharingSameDomain: false;
|
||||||
urlOrigin: string;
|
urlOrigin: string;
|
||||||
urlPathname: string | undefined;
|
urlPathname: string | undefined;
|
||||||
@ -71,11 +76,7 @@ export namespace BuildOptionsLike {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
||||||
const buildOptions = Reflect<BuildOptions>();
|
|
||||||
|
|
||||||
assert<typeof buildOptions extends BuildOptionsLike ? true : false>();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function generateFtlFilesCodeFactory(params: {
|
export function generateFtlFilesCodeFactory(params: {
|
||||||
indexHtmlCode: string;
|
indexHtmlCode: string;
|
||||||
@ -153,7 +154,11 @@ export function generateFtlFilesCodeFactory(params: {
|
|||||||
'{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }': fs
|
'{ "x": "vIdLqMeOed9sdLdIdOxdK0d" }': fs
|
||||||
.readFileSync(pathJoin(__dirname, "ftl_object_to_js_code_declaring_an_object.ftl"))
|
.readFileSync(pathJoin(__dirname, "ftl_object_to_js_code_declaring_an_object.ftl"))
|
||||||
.toString("utf8")
|
.toString("utf8")
|
||||||
.match(/^<script>const _=((?:.|\n)+)<\/script>[\n]?$/)![1],
|
.match(/^<script>const _=((?:.|\n)+)<\/script>[\n]?$/)![1]
|
||||||
|
.replace(
|
||||||
|
"CUSTOM_USER_ATTRIBUTES_eKsIY4ZsZ4xeM",
|
||||||
|
buildOptions.customUserAttributes.length === 0 ? "" : ", " + buildOptions.customUserAttributes.map(name => `"${name}"`).join(", ")
|
||||||
|
),
|
||||||
"<!-- xIdLqMeOedErIdLsPdNdI9dSlxI -->": [
|
"<!-- xIdLqMeOedErIdLsPdNdI9dSlxI -->": [
|
||||||
"<#if scripts??>",
|
"<#if scripts??>",
|
||||||
" <#list scripts as script>",
|
" <#list scripts as script>",
|
||||||
|
@ -9,7 +9,6 @@ import { mockTestingResourcesCommonPath, mockTestingResourcesPath, mockTestingSu
|
|||||||
import { isInside } from "../tools/isInside";
|
import { isInside } from "../tools/isInside";
|
||||||
import type { BuildOptions } from "./BuildOptions";
|
import type { BuildOptions } from "./BuildOptions";
|
||||||
import { assert } from "tsafe/assert";
|
import { assert } from "tsafe/assert";
|
||||||
import { Reflect } from "tsafe/Reflect";
|
|
||||||
|
|
||||||
export type BuildOptionsLike = BuildOptionsLike.Standalone | BuildOptionsLike.ExternalAssets;
|
export type BuildOptionsLike = BuildOptionsLike.Standalone | BuildOptionsLike.ExternalAssets;
|
||||||
|
|
||||||
@ -20,6 +19,7 @@ export namespace BuildOptionsLike {
|
|||||||
extraAccountPages?: string[];
|
extraAccountPages?: string[];
|
||||||
extraThemeProperties?: string[];
|
extraThemeProperties?: string[];
|
||||||
isSilent: boolean;
|
isSilent: boolean;
|
||||||
|
customUserAttributes: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Standalone = Common & {
|
export type Standalone = Common & {
|
||||||
@ -46,11 +46,7 @@ export namespace BuildOptionsLike {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
assert<BuildOptions extends BuildOptionsLike ? true : false>();
|
||||||
const buildOptions = Reflect<BuildOptions>();
|
|
||||||
|
|
||||||
assert<typeof buildOptions extends BuildOptionsLike ? true : false>();
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function generateKeycloakThemeResources(params: {
|
export async function generateKeycloakThemeResources(params: {
|
||||||
reactAppBuildDirPath: string;
|
reactAppBuildDirPath: string;
|
||||||
@ -142,7 +138,7 @@ export async function generateKeycloakThemeResources(params: {
|
|||||||
const { generateFtlFilesCode } = generateFtlFilesCodeFactory({
|
const { generateFtlFilesCode } = generateFtlFilesCodeFactory({
|
||||||
"indexHtmlCode": fs.readFileSync(pathJoin(reactAppBuildDirPath, "index.html")).toString("utf8"),
|
"indexHtmlCode": fs.readFileSync(pathJoin(reactAppBuildDirPath, "index.html")).toString("utf8"),
|
||||||
"cssGlobalsToDefine": allCssGlobalsToDefine,
|
"cssGlobalsToDefine": allCssGlobalsToDefine,
|
||||||
"buildOptions": buildOptions
|
buildOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
return generateFtlFilesCode;
|
return generateFtlFilesCode;
|
||||||
|
@ -24,6 +24,7 @@ type ParsedPackageJson = {
|
|||||||
keycloakVersionDefaultAssets?: string;
|
keycloakVersionDefaultAssets?: string;
|
||||||
appInputPath?: string;
|
appInputPath?: string;
|
||||||
keycloakBuildPath?: string;
|
keycloakBuildPath?: string;
|
||||||
|
customUserAttributes?: string[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -43,7 +44,8 @@ const zParsedPackageJson = z.object({
|
|||||||
"bundler": z.enum(bundlers).optional(),
|
"bundler": z.enum(bundlers).optional(),
|
||||||
"keycloakVersionDefaultAssets": z.string().optional(),
|
"keycloakVersionDefaultAssets": z.string().optional(),
|
||||||
"appInputPath": z.string().optional(),
|
"appInputPath": z.string().optional(),
|
||||||
"keycloakBuildPath": z.string().optional()
|
"keycloakBuildPath": z.string().optional(),
|
||||||
|
"customUserAttributes": z.array(z.string()).optional()
|
||||||
})
|
})
|
||||||
.optional()
|
.optional()
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user