diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4435b228..e3a63c0a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,7 +32,7 @@ jobs: steps: - name: Tell if project is using npm or yarn id: step1 - uses: garronej/ts-ci@v1.1.3 + uses: garronej/ts-ci@v1.1.6 with: action_name: tell_if_project_uses_npm_or_yarn - uses: actions/checkout@v2.3.4 @@ -64,7 +64,7 @@ jobs: is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }} is_release_beta: ${{steps.step1.outputs.is_release_beta }} steps: - - uses: garronej/ts-ci@v1.1.3 + - uses: garronej/ts-ci@v1.1.6 id: step1 with: action_name: is_package_json_version_upgraded @@ -75,7 +75,7 @@ jobs: needs: check_if_version_upgraded if: needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' steps: - - uses: garronej/ts-ci@v1.1.3 + - uses: garronej/ts-ci@v1.1.6 with: action_name: update_changelog branch: ${{ github.head_ref || github.ref }} diff --git a/package.json b/package.json index 4a20108d..474f5189 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "keycloakify", - "version": "4.5.1", + "version": "4.5.2-beta.0", "description": "Keycloak theme generator for Reacts app", "repository": { "type": "git", diff --git a/src/bin/build-keycloak-theme/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl b/src/bin/build-keycloak-theme/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl index b1e6627d..0b6d808b 100644 --- a/src/bin/build-keycloak-theme/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl +++ b/src/bin/build-keycloak-theme/generateFtl/ftl_object_to_js_code_declaring_an_object.ftl @@ -126,6 +126,14 @@ ${ftl_object_to_js_code_declaring_an_object(.data_model, [])?no_esc}; key == "loginAction" && are_same_path(path, ["url"]) && pageId == "saml-post-form.ftl" + ) || ( + ["contextData", "idpConfig", "idp", "authenticationSession"]?seq_contains(key) && + are_same_path(path, ["brokerContext"]) && + ["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(pageId) + ) || ( + key == "identityProviderBrokerCtx" && + are_same_path(path, []) && + ["login-idp-link-confirm.ftl", "login-idp-link-email.ftl" ]?seq_contains(pageId) ) > <#local out_seq += ["/*If you need '" + key + "' on " + pageId + ", please submit an issue to the Keycloakify repo*/"]> diff --git a/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts b/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts index bbd8c598..b024bc31 100644 --- a/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts +++ b/src/bin/build-keycloak-theme/generateKeycloakThemeResources.ts @@ -1,6 +1,6 @@ import { transformCodebase } from "../tools/transformCodebase"; import * as fs from "fs"; -import { join as pathJoin } from "path"; +import { join as pathJoin, basename as pathBasename } from "path"; import { replaceImportsInCssCode, replaceImportsFromStaticInJsCode } from "./replaceImportFromStatic"; import { generateFtlFilesCodeFactory, pageIds } from "./generateFtl"; import { downloadBuiltinKeycloakTheme } from "../download-builtin-keycloak-theme"; @@ -112,20 +112,22 @@ export function generateKeycloakThemeResources(params: { const reactAppPublicDirPath = pathJoin(reactAppBuildDirPath, "..", "public"); transformCodebase({ - "srcDirPath": themeResourcesDirPath, - "destDirPath": pathJoin(reactAppPublicDirPath, resourcesPath), + "srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"), + "destDirPath": pathJoin(themeResourcesDirPath, pathBasename(resourcesCommonPath)), }); transformCodebase({ - "srcDirPath": pathJoin(tmpDirPath, "keycloak", "common", "resources"), - "destDirPath": pathJoin(reactAppPublicDirPath, resourcesCommonPath), + "srcDirPath": themeResourcesDirPath, + "destDirPath": pathJoin(reactAppPublicDirPath, resourcesPath), }); const keycloakResourcesWithinPublicDirPath = pathJoin(reactAppPublicDirPath, subDirOfPublicDirBasename); fs.writeFileSync( pathJoin(keycloakResourcesWithinPublicDirPath, "README.txt"), - Buffer.from(["This is just a test folder that helps develop", "the login and register page without having to yarn build"].join(" ")), + Buffer.from( + ["This is just a test folder that helps develop", "the login and register page without having to run a Keycloak container"].join(" "), + ), ); fs.writeFileSync(pathJoin(keycloakResourcesWithinPublicDirPath, ".gitignore"), Buffer.from("*", "utf8")); diff --git a/src/lib/getKcContext/getKcContext.ts b/src/lib/getKcContext/getKcContext.ts index 7c076fb3..4b298cce 100644 --- a/src/lib/getKcContext/getKcContext.ts +++ b/src/lib/getKcContext/getKcContext.ts @@ -7,6 +7,9 @@ import { exclude } from "tsafe/exclude"; import { assert } from "tsafe/assert"; import type { ExtendsKcContextBase } from "./getKcContextFromWindow"; import { getKcContextFromWindow } from "./getKcContextFromWindow"; +import { pathJoin } from "../tools/pathJoin"; +import { pathBasename } from "../tools/pathBasename"; +import { resourcesCommonPath } from "./kcContextMocks/urlResourcesPath"; export function getKcContext(params?: { mockPageId?: ExtendsKcContextBase["pageId"]; @@ -93,5 +96,13 @@ export function getKcContext() }; + const kcContext = getKcContextFromWindow(); + + if (kcContext !== undefined) { + const { url } = kcContext; + + url.resourcesCommonPath = pathJoin(url.resourcesPath, pathBasename(resourcesCommonPath)); + } + + return { kcContext }; } diff --git a/src/lib/getKcContext/kcContextMocks/urlResourcesPath.ts b/src/lib/getKcContext/kcContextMocks/urlResourcesPath.ts index 542126dd..232433b9 100644 --- a/src/lib/getKcContext/kcContextMocks/urlResourcesPath.ts +++ b/src/lib/getKcContext/kcContextMocks/urlResourcesPath.ts @@ -2,4 +2,4 @@ import { pathJoin } from "../../tools/pathJoin"; export const subDirOfPublicDirBasename = "keycloak_static"; export const resourcesPath = pathJoin(subDirOfPublicDirBasename, "resources"); -export const resourcesCommonPath = pathJoin(subDirOfPublicDirBasename, "resources_common"); +export const resourcesCommonPath = pathJoin(resourcesPath, "resources_common"); diff --git a/src/lib/tools/pathBasename.ts b/src/lib/tools/pathBasename.ts new file mode 100644 index 00000000..48952963 --- /dev/null +++ b/src/lib/tools/pathBasename.ts @@ -0,0 +1,3 @@ +export function pathBasename(path: string) { + return path.split("/").reverse()[0]; +}