route the pages removed in kc 24 at low level
This commit is contained in:
parent
78517164d4
commit
8d21425ae0
@ -1,12 +1,12 @@
|
|||||||
import { assert } from "tsafe/assert";
|
import { assert, type Equals } from "tsafe/assert";
|
||||||
import type { KeycloakAccountV1Version, KeycloakThemeAdditionalInfoExtensionVersion } from "./extensionVersions";
|
import type { KeycloakAccountV1Version, KeycloakThemeAdditionalInfoExtensionVersion } from "./extensionVersions";
|
||||||
import { join as pathJoin } from "path";
|
import { join as pathJoin, dirname as pathDirname } from "path";
|
||||||
import { transformCodebase } from "../../tools/transformCodebase";
|
import { transformCodebase } from "../../tools/transformCodebase";
|
||||||
import type { BuildOptions } from "../buildOptions";
|
import type { BuildOptions } from "../buildOptions";
|
||||||
import * as fs from "fs/promises";
|
import * as fs from "fs/promises";
|
||||||
import { accountV1ThemeName } from "../../constants";
|
import { accountV1ThemeName } from "../../constants";
|
||||||
import { generatePom, BuildOptionsLike as BuildOptionsLike_generatePom } from "./generatePom";
|
import { generatePom, BuildOptionsLike as BuildOptionsLike_generatePom } from "./generatePom";
|
||||||
import { existsSync } from "fs";
|
import { existsSync, readFileSync } from "fs";
|
||||||
import { isInside } from "../../tools/isInside";
|
import { isInside } from "../../tools/isInside";
|
||||||
import child_process from "child_process";
|
import child_process from "child_process";
|
||||||
|
|
||||||
@ -37,9 +37,9 @@ export async function buildJar(params: {
|
|||||||
await fs.writeFile(pathJoin(buildOptions.keycloakifyBuildDirPath, ".gitignore"), Buffer.from("*", "utf8"));
|
await fs.writeFile(pathJoin(buildOptions.keycloakifyBuildDirPath, ".gitignore"), Buffer.from("*", "utf8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
const srcMainResourcesRelativeDirPath = pathJoin("src", "main", "resources");
|
||||||
const srcMainResourcesRelativeDirPath = pathJoin("src", "main", "resources");
|
|
||||||
|
|
||||||
|
{
|
||||||
const keycloakThemesJsonFilePath = pathJoin(srcMainResourcesRelativeDirPath, "META-INF", "keycloak-themes.json");
|
const keycloakThemesJsonFilePath = pathJoin(srcMainResourcesRelativeDirPath, "META-INF", "keycloak-themes.json");
|
||||||
|
|
||||||
const themePropertiesFilePathSet = new Set(
|
const themePropertiesFilePathSet = new Set(
|
||||||
@ -87,6 +87,53 @@ export async function buildJar(params: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
route_legacy_pages: {
|
||||||
|
// NOTE: If there's no account theme there is no special target for keycloak 24 and up so we create
|
||||||
|
// the pages anyway. If there is an account pages, since we know that account-v1 is only support keycloak
|
||||||
|
// 24 in version 0.4 and up, we can safely break the route for legacy pages.
|
||||||
|
const doBreak: boolean = (() => {
|
||||||
|
switch (keycloakAccountV1Version) {
|
||||||
|
case null:
|
||||||
|
return false;
|
||||||
|
case "0.3":
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (doBreak) {
|
||||||
|
break route_legacy_pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
(["register.ftl", "login-update-profile.ftl"] as const).forEach(pageId =>
|
||||||
|
buildOptions.themeNames.map(themeName => {
|
||||||
|
const ftlFilePath = pathJoin(srcMainResourcesRelativeDirPath, "themes", themeName, "login", pageId);
|
||||||
|
|
||||||
|
const ftlFileContent = readFileSync(ftlFilePath).toString("utf8");
|
||||||
|
|
||||||
|
const realPageId = (() => {
|
||||||
|
switch (pageId) {
|
||||||
|
case "register.ftl":
|
||||||
|
return "register-user-profile.ftl";
|
||||||
|
case "login-update-profile.ftl":
|
||||||
|
return "update-user-profile.ftl";
|
||||||
|
}
|
||||||
|
assert<Equals<typeof pageId, never>>(false);
|
||||||
|
})();
|
||||||
|
|
||||||
|
const modifiedFtlFileContent = ftlFileContent.replace(
|
||||||
|
`out["pageId"] = "${pageId}";`,
|
||||||
|
`out["pageId"] = "${pageId}"; out["realPageId"] = "${realPageId}";`
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(modifiedFtlFileContent !== ftlFileContent);
|
||||||
|
|
||||||
|
fs.writeFile(pathJoin(pathDirname(ftlFilePath), realPageId), Buffer.from(modifiedFtlFileContent, "utf8"));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const { pomFileCode } = generatePom({
|
const { pomFileCode } = generatePom({
|
||||||
buildOptions,
|
buildOptions,
|
||||||
|
@ -5,7 +5,6 @@ export const loginThemePageIds = [
|
|||||||
"webauthn-authenticate.ftl",
|
"webauthn-authenticate.ftl",
|
||||||
"webauthn-register.ftl",
|
"webauthn-register.ftl",
|
||||||
"register.ftl",
|
"register.ftl",
|
||||||
"register-user-profile.ftl",
|
|
||||||
"info.ftl",
|
"info.ftl",
|
||||||
"error.ftl",
|
"error.ftl",
|
||||||
"login-reset-password.ftl",
|
"login-reset-password.ftl",
|
||||||
@ -21,7 +20,6 @@ export const loginThemePageIds = [
|
|||||||
"login-page-expired.ftl",
|
"login-page-expired.ftl",
|
||||||
"login-config-totp.ftl",
|
"login-config-totp.ftl",
|
||||||
"logout-confirm.ftl",
|
"logout-confirm.ftl",
|
||||||
"update-user-profile.ftl",
|
|
||||||
"idp-review-user-profile.ftl",
|
"idp-review-user-profile.ftl",
|
||||||
"update-email.ftl",
|
"update-email.ftl",
|
||||||
"select-authenticator.ftl",
|
"select-authenticator.ftl",
|
||||||
|
@ -55,7 +55,6 @@ export default function Fallback(props: FallbackProps) {
|
|||||||
case "login.ftl":
|
case "login.ftl":
|
||||||
return <Login kcContext={kcContext} {...rest} />;
|
return <Login kcContext={kcContext} {...rest} />;
|
||||||
case "register.ftl":
|
case "register.ftl":
|
||||||
case "register-user-profile.ftl":
|
|
||||||
return <Register kcContext={kcContext} {...rest} />;
|
return <Register kcContext={kcContext} {...rest} />;
|
||||||
case "info.ftl":
|
case "info.ftl":
|
||||||
return <Info kcContext={kcContext} {...rest} />;
|
return <Info kcContext={kcContext} {...rest} />;
|
||||||
@ -84,7 +83,6 @@ export default function Fallback(props: FallbackProps) {
|
|||||||
case "login-update-password.ftl":
|
case "login-update-password.ftl":
|
||||||
return <LoginUpdatePassword kcContext={kcContext} {...rest} />;
|
return <LoginUpdatePassword kcContext={kcContext} {...rest} />;
|
||||||
case "login-update-profile.ftl":
|
case "login-update-profile.ftl":
|
||||||
case "update-user-profile.ftl":
|
|
||||||
return <LoginUpdateProfile kcContext={kcContext} {...rest} />;
|
return <LoginUpdateProfile kcContext={kcContext} {...rest} />;
|
||||||
case "login-idp-link-confirm.ftl":
|
case "login-idp-link-confirm.ftl":
|
||||||
return <LoginIdpLinkConfirm kcContext={kcContext} {...rest} />;
|
return <LoginIdpLinkConfirm kcContext={kcContext} {...rest} />;
|
||||||
|
@ -183,7 +183,7 @@ export declare namespace KcContext {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type Register = Common & {
|
export type Register = Common & {
|
||||||
pageId: "register.ftl" | "register-user-profile.ftl";
|
pageId: "register.ftl";
|
||||||
profile: UserProfile;
|
profile: UserProfile;
|
||||||
url: {
|
url: {
|
||||||
registrationAction: string;
|
registrationAction: string;
|
||||||
@ -452,7 +452,7 @@ export declare namespace KcContext {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type LoginUpdateProfile = Common & {
|
export type LoginUpdateProfile = Common & {
|
||||||
pageId: "login-update-profile.ftl" | "update-user-profile.ftl";
|
pageId: "login-update-profile.ftl";
|
||||||
profile: UserProfile;
|
profile: UserProfile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import type { I18n } from "../i18n";
|
|||||||
import type { LazyOrNot } from "keycloakify/tools/LazyOrNot";
|
import type { LazyOrNot } from "keycloakify/tools/LazyOrNot";
|
||||||
import type { UserProfileFormFieldsProps } from "keycloakify/login/UserProfileFormFields";
|
import type { UserProfileFormFieldsProps } from "keycloakify/login/UserProfileFormFields";
|
||||||
|
|
||||||
type LoginUpdateProfileProps = PageProps<Extract<KcContext, { pageId: "login-update-profile.ftl" | "update-user-profile.ftl" }>, I18n> & {
|
type LoginUpdateProfileProps = PageProps<Extract<KcContext, { pageId: "login-update-profile.ftl" }>, I18n> & {
|
||||||
UserProfileFormFields: LazyOrNot<(props: UserProfileFormFieldsProps) => JSX.Element>;
|
UserProfileFormFields: LazyOrNot<(props: UserProfileFormFieldsProps) => JSX.Element>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import { Markdown } from "keycloakify/tools/Markdown";
|
|||||||
import type { KcContext } from "../kcContext";
|
import type { KcContext } from "../kcContext";
|
||||||
import type { I18n } from "../i18n";
|
import type { I18n } from "../i18n";
|
||||||
|
|
||||||
type RegisterProps = PageProps<Extract<KcContext, { pageId: "register.ftl" | "register-user-profile.ftl" }>, I18n> & {
|
type RegisterProps = PageProps<Extract<KcContext, { pageId: "register.ftl" }>, I18n> & {
|
||||||
UserProfileFormFields: LazyOrNot<(props: UserProfileFormFieldsProps) => JSX.Element>;
|
UserProfileFormFields: LazyOrNot<(props: UserProfileFormFieldsProps) => JSX.Element>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user