Enable possiblity to support custom pages (without forking keycloakify)
This commit is contained in:
parent
e3b41c9bd1
commit
c9b2db625c
@ -6,7 +6,6 @@ import * as child_process from "child_process";
|
|||||||
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
|
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
|
|
||||||
|
|
||||||
const reactProjectDirPath = process.cwd();
|
const reactProjectDirPath = process.cwd();
|
||||||
|
|
||||||
const doUseExternalAssets = process.argv[2]?.toLowerCase() === "--external-assets";
|
const doUseExternalAssets = process.argv[2]?.toLowerCase() === "--external-assets";
|
||||||
@ -19,6 +18,8 @@ export function main() {
|
|||||||
|
|
||||||
console.log("🔏 Building the keycloak theme...⌚");
|
console.log("🔏 Building the keycloak theme...⌚");
|
||||||
|
|
||||||
|
const extraPagesId: string[] = (parsedPackageJson as any)["keycloakify"]?.["extraPages"] ?? [];
|
||||||
|
|
||||||
generateKeycloakThemeResources({
|
generateKeycloakThemeResources({
|
||||||
keycloakThemeBuildingDirPath,
|
keycloakThemeBuildingDirPath,
|
||||||
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
|
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
|
||||||
@ -53,7 +54,8 @@ export function main() {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
})()
|
})(),
|
||||||
|
extraPagesId
|
||||||
});
|
});
|
||||||
|
|
||||||
const { jarFilePath } = generateJavaStackFiles({
|
const { jarFilePath } = generateJavaStackFiles({
|
||||||
|
@ -136,7 +136,7 @@ export function generateFtlFilesCodeFactory(
|
|||||||
|
|
||||||
function generateFtlFilesCode(
|
function generateFtlFilesCode(
|
||||||
params: {
|
params: {
|
||||||
pageId: PageId;
|
pageId: string;
|
||||||
}
|
}
|
||||||
): { ftlCode: string; } {
|
): { ftlCode: string; } {
|
||||||
|
|
||||||
|
@ -22,10 +22,14 @@ export function generateKeycloakThemeResources(
|
|||||||
urlPathname: string;
|
urlPathname: string;
|
||||||
//If urlOrigin is not undefined then it means --externals-assets
|
//If urlOrigin is not undefined then it means --externals-assets
|
||||||
urlOrigin: undefined | string;
|
urlOrigin: undefined | string;
|
||||||
|
extraPagesId: string[];
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const { themeName, reactAppBuildDirPath, keycloakThemeBuildingDirPath, urlPathname, urlOrigin } = params;
|
const {
|
||||||
|
themeName, reactAppBuildDirPath, keycloakThemeBuildingDirPath,
|
||||||
|
urlPathname, urlOrigin, extraPagesId
|
||||||
|
} = params;
|
||||||
|
|
||||||
const themeDirPath = pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", themeName, "login");
|
const themeDirPath = pathJoin(keycloakThemeBuildingDirPath, "src", "main", "resources", "theme", themeName, "login");
|
||||||
|
|
||||||
@ -92,7 +96,7 @@ export function generateKeycloakThemeResources(
|
|||||||
urlOrigin
|
urlOrigin
|
||||||
});
|
});
|
||||||
|
|
||||||
pageIds.forEach(pageId => {
|
[...pageIds, ...extraPagesId].forEach(pageId => {
|
||||||
|
|
||||||
const { ftlCode } = generateFtlFilesCode({ pageId });
|
const { ftlCode } = generateFtlFilesCode({ pageId });
|
||||||
|
|
||||||
|
@ -123,11 +123,6 @@ export declare namespace KcContextBase {
|
|||||||
passwordRequired: boolean;
|
passwordRequired: boolean;
|
||||||
recaptchaRequired: boolean;
|
recaptchaRequired: boolean;
|
||||||
recaptchaSiteKey?: string;
|
recaptchaSiteKey?: string;
|
||||||
/**
|
|
||||||
* Defined when you use the keycloak-mail-whitelisting keycloak plugin
|
|
||||||
* (https://github.com/micedre/keycloak-mail-whitelisting)
|
|
||||||
*/
|
|
||||||
authorizedMailDomains?: string[];
|
|
||||||
social: {
|
social: {
|
||||||
displayInfo: boolean;
|
displayInfo: boolean;
|
||||||
providers?: {
|
providers?: {
|
||||||
|
@ -5,14 +5,14 @@ import { ftlValuesGlobalName } from "../../bin/build-keycloak-theme/ftlValuesGlo
|
|||||||
|
|
||||||
export function getKcContext<KcContextExtended extends { pageId: string; } = never>(
|
export function getKcContext<KcContextExtended extends { pageId: string; } = never>(
|
||||||
params?: {
|
params?: {
|
||||||
mockPageId: KcContextBase["pageId"] | KcContextExtended["pageId"] | false;
|
mockPageId?: KcContextBase["pageId"] | KcContextExtended["pageId"];
|
||||||
kcContextExtendedMock?: KcContextExtended[];
|
kcContextExtendedMock?: KcContextExtended[];
|
||||||
}
|
}
|
||||||
): { kcContext: KcContextBase | KcContextExtended & KcContextBase.Common; } {
|
): { kcContext: (KcContextBase | KcContextExtended & KcContextBase.Common) | undefined; } {
|
||||||
|
|
||||||
const { mockPageId, kcContextExtendedMock } = params ?? { "mockPageId": false };
|
const { mockPageId, kcContextExtendedMock } = params ?? { "mockPageId": false };
|
||||||
|
|
||||||
if (typeof mockPageId === "string") {
|
if (mockPageId !== undefined) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"pageId": mockPageId,
|
"pageId": mockPageId,
|
||||||
|
@ -166,13 +166,6 @@ export const kcContextMocks: KcContextBase[] = [
|
|||||||
},
|
},
|
||||||
"passwordRequired": true,
|
"passwordRequired": true,
|
||||||
"recaptchaRequired": false,
|
"recaptchaRequired": false,
|
||||||
"authorizedMailDomains": [
|
|
||||||
"example.com",
|
|
||||||
"another-example.com",
|
|
||||||
"*.yet-another-example.com",
|
|
||||||
"*.example.com",
|
|
||||||
"hello-world.com"
|
|
||||||
],
|
|
||||||
"social": {
|
"social": {
|
||||||
"displayInfo": true
|
"displayInfo": true
|
||||||
},
|
},
|
||||||
|
@ -13,6 +13,7 @@ generateKeycloakThemeResources({
|
|||||||
"reactAppBuildDirPath": pathJoin(sampleReactProjectDirPath, "build"),
|
"reactAppBuildDirPath": pathJoin(sampleReactProjectDirPath, "build"),
|
||||||
"keycloakThemeBuildingDirPath": pathJoin(sampleReactProjectDirPath, "build_keycloak_theme"),
|
"keycloakThemeBuildingDirPath": pathJoin(sampleReactProjectDirPath, "build_keycloak_theme"),
|
||||||
"urlPathname": "/keycloakify-demo-app/",
|
"urlPathname": "/keycloakify-demo-app/",
|
||||||
"urlOrigin": undefined
|
"urlOrigin": undefined,
|
||||||
|
"extraPagesId": ["my-custom-page.ftl"]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user