Fix some bugs in start-keycloak

This commit is contained in:
Joseph Garrone 2024-05-20 19:30:04 +02:00
parent ee5f73519a
commit b34f86d2f0
3 changed files with 2247 additions and 78 deletions

File diff suppressed because it is too large Load Diff

View File

@ -598,7 +598,9 @@
"publicClient": true, "publicClient": true,
"frontchannelLogout": false, "frontchannelLogout": false,
"protocol": "openid-connect", "protocol": "openid-connect",
"attributes": {}, "attributes": {
"post.logout.redirect.uris": "+"
},
"authenticationFlowBindingOverrides": {}, "authenticationFlowBindingOverrides": {},
"fullScopeAllowed": false, "fullScopeAllowed": false,
"nodeReRegistrationTimeout": 0, "nodeReRegistrationTimeout": 0,
@ -630,7 +632,9 @@
"publicClient": false, "publicClient": false,
"frontchannelLogout": false, "frontchannelLogout": false,
"protocol": "openid-connect", "protocol": "openid-connect",
"attributes": {}, "attributes": {
"post.logout.redirect.uris": "+"
},
"authenticationFlowBindingOverrides": {}, "authenticationFlowBindingOverrides": {},
"fullScopeAllowed": false, "fullScopeAllowed": false,
"nodeReRegistrationTimeout": 0, "nodeReRegistrationTimeout": 0,
@ -812,7 +816,9 @@
"publicClient": false, "publicClient": false,
"frontchannelLogout": false, "frontchannelLogout": false,
"protocol": "openid-connect", "protocol": "openid-connect",
"attributes": {}, "attributes": {
"post.logout.redirect.uris": "+"
},
"authenticationFlowBindingOverrides": {}, "authenticationFlowBindingOverrides": {},
"fullScopeAllowed": false, "fullScopeAllowed": false,
"nodeReRegistrationTimeout": 0, "nodeReRegistrationTimeout": 0,
@ -955,7 +961,8 @@
"config": { "config": {
"id.token.claim": "true", "id.token.claim": "true",
"introspection.token.claim": "true", "introspection.token.claim": "true",
"access.token.claim": "true" "access.token.claim": "true",
"userinfo.token.claim": "true"
} }
} }
] ]
@ -995,6 +1002,7 @@
"config": { "config": {
"introspection.token.claim": "true", "introspection.token.claim": "true",
"multivalued": "true", "multivalued": "true",
"userinfo.token.claim": "true",
"user.attribute": "foo", "user.attribute": "foo",
"id.token.claim": "true", "id.token.claim": "true",
"access.token.claim": "true", "access.token.claim": "true",
@ -1444,7 +1452,7 @@
}, },
"smtpServer": {}, "smtpServer": {},
"loginTheme": "keycloak", "loginTheme": "keycloak",
"accountTheme": "account-v1", "accountTheme": "keycloakify-starter",
"adminTheme": "", "adminTheme": "",
"emailTheme": "", "emailTheme": "",
"eventsEnabled": false, "eventsEnabled": false,
@ -1493,14 +1501,14 @@
"subComponents": {}, "subComponents": {},
"config": { "config": {
"allowed-protocol-mapper-types": [ "allowed-protocol-mapper-types": [
"oidc-address-mapper",
"oidc-full-name-mapper",
"oidc-usermodel-attribute-mapper",
"saml-user-attribute-mapper",
"oidc-sha256-pairwise-sub-mapper", "oidc-sha256-pairwise-sub-mapper",
"saml-role-list-mapper", "saml-role-list-mapper",
"oidc-address-mapper",
"oidc-usermodel-property-mapper",
"saml-user-attribute-mapper",
"oidc-full-name-mapper",
"saml-user-property-mapper", "saml-user-property-mapper",
"oidc-usermodel-property-mapper" "oidc-usermodel-attribute-mapper"
] ]
} }
}, },
@ -1532,13 +1540,13 @@
"subComponents": {}, "subComponents": {},
"config": { "config": {
"allowed-protocol-mapper-types": [ "allowed-protocol-mapper-types": [
"oidc-usermodel-attribute-mapper",
"saml-user-property-mapper",
"oidc-address-mapper",
"saml-role-list-mapper",
"oidc-sha256-pairwise-sub-mapper", "oidc-sha256-pairwise-sub-mapper",
"saml-user-attribute-mapper", "saml-user-property-mapper",
"oidc-usermodel-attribute-mapper",
"oidc-address-mapper",
"oidc-usermodel-property-mapper", "oidc-usermodel-property-mapper",
"saml-role-list-mapper",
"saml-user-attribute-mapper",
"oidc-full-name-mapper" "oidc-full-name-mapper"
] ]
} }
@ -2290,8 +2298,8 @@
"cibaExpiresIn": "120", "cibaExpiresIn": "120",
"cibaAuthRequestedUserHint": "login_hint", "cibaAuthRequestedUserHint": "login_hint",
"oauth2DeviceCodeLifespan": "600", "oauth2DeviceCodeLifespan": "600",
"oauth2DevicePollingInterval": "5",
"clientOfflineSessionMaxLifespan": "0", "clientOfflineSessionMaxLifespan": "0",
"oauth2DevicePollingInterval": "5",
"clientSessionIdleTimeout": "0", "clientSessionIdleTimeout": "0",
"parRequestUriLifespan": "60", "parRequestUriLifespan": "60",
"clientSessionMaxLifespan": "0", "clientSessionMaxLifespan": "0",

View File

@ -27,6 +27,7 @@ import { Deferred } from "evt/tools/Deferred";
import { getAbsoluteAndInOsFormatPath } from "../tools/getAbsoluteAndInOsFormatPath"; import { getAbsoluteAndInOsFormatPath } from "../tools/getAbsoluteAndInOsFormatPath";
import cliSelect from "cli-select"; import cliSelect from "cli-select";
import { isInside } from "../tools/isInside"; import { isInside } from "../tools/isInside";
import * as runExclusive from "run-exclusive";
export type CliCommandOptions = CliCommandOptions_common & { export type CliCommandOptions = CliCommandOptions_common & {
port: number; port: number;
@ -396,6 +397,70 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
} }
{ {
const runBuildKeycloakTheme = runExclusive.build(async () => {
console.log(chalk.cyan("Detected changes in the theme. Rebuilding ..."));
{
const dResult = new Deferred<{ isSuccess: boolean }>();
const child = child_process.spawn("npx", ["vite", "build"], {
cwd: buildOptions.reactAppRootDirPath,
env: process.env
});
child.stdout.on("data", data => {
if (data.toString("utf8").includes("gzip:")) {
return;
}
process.stdout.write(data);
});
child.stderr.on("data", data => process.stderr.write(data));
child.on("exit", code => dResult.resolve({ isSuccess: code === 0 }));
const { isSuccess } = await dResult.pr;
if (!isSuccess) {
return;
}
}
{
const dResult = new Deferred<{ isSuccess: boolean }>();
const child = child_process.spawn("npx", ["keycloakify", "build"], {
cwd: buildOptions.reactAppRootDirPath,
env: {
...process.env,
[skipBuildJarsEnvName]: "true"
}
});
child.stdout.on("data", data => process.stdout.write(data));
child.stderr.on("data", data => process.stderr.write(data));
child.on("exit", code => {
if (code !== 0) {
console.log(chalk.yellow("Theme not updated, build failed"));
return;
}
console.log(chalk.green("Rebuild done"));
});
child.on("exit", code => dResult.resolve({ isSuccess: code === 0 }));
const { isSuccess } = await dResult.pr;
if (!isSuccess) {
return;
}
}
});
const { waitForDebounce } = waitForDebounceFactory({ delay: 400 }); const { waitForDebounce } = waitForDebounceFactory({ delay: 400 });
chokidar chokidar
@ -403,72 +468,26 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
ignoreInitial: true ignoreInitial: true
}) })
.on("all", async (...[, filePath]) => { .on("all", async (...[, filePath]) => {
if ( for (const dir1 of ["src", "."]) {
isInside({ for (const dir2 of ["bin", "vite-plugin"]) {
dirPath: pathJoin(getThisCodebaseRootDirPath(), "src", "bin"), if (
filePath isInside({
}) || dirPath: pathJoin(
isInside({ getThisCodebaseRootDirPath(),
dirPath: pathJoin(getThisCodebaseRootDirPath(), "bin"), dir1,
filePath dir2
}) ),
) { filePath
return; })
) {
return;
}
}
} }
await waitForDebounce(); await waitForDebounce();
console.log(chalk.cyan("Detected changes in the theme. Rebuilding ...")); runBuildKeycloakTheme();
const dViteBuildDone = new Deferred<void>();
{
const child = child_process.spawn("npx", ["vite", "build"], {
cwd: buildOptions.reactAppRootDirPath,
env: process.env
});
child.stdout.on("data", data => {
if (data.toString("utf8").includes("gzip:")) {
return;
}
process.stdout.write(data);
});
child.stderr.on("data", data => process.stderr.write(data));
child.on("exit", code => {
if (code === 0) {
dViteBuildDone.resolve();
}
});
}
await dViteBuildDone.pr;
{
const child = child_process.spawn("npx", ["keycloakify", "build"], {
cwd: buildOptions.reactAppRootDirPath,
env: {
...process.env,
[skipBuildJarsEnvName]: "true"
}
});
child.stdout.on("data", data => process.stdout.write(data));
child.stderr.on("data", data => process.stderr.write(data));
child.on("exit", code => {
if (code !== 0) {
console.log(chalk.yellow("Theme not updated, build failed"));
return;
}
console.log(chalk.green("Rebuild done"));
});
}
}); });
} }
} }