Skip to content

Commit 78c806c

Browse files
feat: Implement a shared Keycloak deployment and support modular auth configurations (#8)
* keycloak helper * Refactor RHDH deployment to support modular auth configurations
1 parent ef39082 commit 78c806c

27 files changed

Lines changed: 1282 additions & 180 deletions

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@
3535
"./pages": {
3636
"types": "./dist/playwright/pages/index.d.ts",
3737
"default": "./dist/playwright/pages/index.js"
38+
},
39+
"./keycloak": {
40+
"types": "./dist/deployment/keycloak/index.d.ts",
41+
"default": "./dist/deployment/keycloak/index.js"
3842
}
3943
},
4044
"files": [
4145
"dist",
4246
"tsconfig.base.json"
4347
],
4448
"scripts": {
45-
"build": "yarn clean && tsc -p tsconfig.build.json && cp -r src/deployment/rhdh/config src/deployment/rhdh/helm src/deployment/rhdh/operator dist/deployment/rhdh/",
49+
"build": "yarn clean && tsc -p tsconfig.build.json && cp -r src/deployment/rhdh/config dist/deployment/rhdh/ && cp -r src/deployment/keycloak/config dist/deployment/keycloak/",
4650
"check": "yarn typecheck && yarn lint:check && yarn prettier:check",
4751
"clean": "rm -rf dist",
4852
"lint:check": "eslint . --ignore-pattern dist --ignore-pattern README.md",
@@ -76,6 +80,7 @@
7680
"dependencies": {
7781
"@axe-core/playwright": "^4.11.0",
7882
"@eslint/js": "^9.39.1",
83+
"@keycloak/keycloak-admin-client": "^26.0.0",
7984
"@kubernetes/client-node": "^1.4.0",
8085
"boxen": "^8.0.1",
8186
"eslint": "^9.39.1",
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
global:
2+
security:
3+
allowInsecureImages: true
4+
5+
replicaCount: 1
6+
7+
# Use Bitnami legacy repository (Bitnami images moved to bitnamilegacy as of Aug 2025)
8+
# Note: Legacy images are not updated/maintained. Consider migrating to official Keycloak image for long-term.
9+
image:
10+
registry: docker.io
11+
repository: bitnamilegacy/keycloak
12+
tag: "26.3.3-debian-12-r0"
13+
pullPolicy: IfNotPresent
14+
15+
auth:
16+
adminUser: admin
17+
adminPassword: admin123
18+
19+
service:
20+
type: ClusterIP
21+
port: 8080
22+
23+
# OpenShift Route configuration
24+
route:
25+
enabled: true
26+
host: "" # Will be auto-generated by OpenShift
27+
tls:
28+
enabled: false
29+
30+
ingress:
31+
enabled: false
32+
33+
postgresql:
34+
enabled: true
35+
image:
36+
registry: docker.io
37+
repository: bitnamilegacy/postgresql
38+
tag: "17.6.0-debian-12-r4"
39+
pullPolicy: IfNotPresent
40+
auth:
41+
postgresPassword: postgres123
42+
username: keycloak
43+
password: keycloak123
44+
database: keycloak
45+
primary:
46+
resources:
47+
limits:
48+
cpu: 1000m
49+
memory: 1Gi
50+
requests:
51+
cpu: 100m
52+
memory: 256Mi
53+
persistence:
54+
enabled: true
55+
size: 1Gi
56+
57+
resources:
58+
limits:
59+
cpu: 1000m
60+
memory: 1Gi
61+
requests:
62+
cpu: 100m
63+
memory: 256Mi
64+
65+
extraEnvVars:
66+
- name: KEYCLOAK_ADMIN
67+
value: admin
68+
- name: KEYCLOAK_ADMIN_PASSWORD
69+
value: admin123
70+
- name: KC_HTTP_ENABLED
71+
value: "true"
72+
- name: KC_PROXY_HEADERS
73+
value: "xforwarded"
74+
- name: KC_HOSTNAME_STRICT
75+
value: "false"
76+
- name: JAVA_OPTS_APPEND
77+
value: "-Djava.net.preferIPv4Stack=true -Xms256m -Xmx512m"
78+
79+
# Increase probe timeouts for slower startup on resource-constrained clusters
80+
livenessProbe:
81+
enabled: true
82+
initialDelaySeconds: 120
83+
periodSeconds: 10
84+
timeoutSeconds: 5
85+
failureThreshold: 6
86+
successThreshold: 1
87+
88+
readinessProbe:
89+
enabled: true
90+
initialDelaySeconds: 60
91+
periodSeconds: 10
92+
timeoutSeconds: 5
93+
failureThreshold: 6
94+
successThreshold: 1
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import path from "path";
2+
import type { KeycloakClientConfig } from "./types.js";
3+
4+
// Navigate from dist/deployment/keycloak/ to package root
5+
const PACKAGE_ROOT = path.resolve(import.meta.dirname, "../../..");
6+
7+
export const DEFAULT_KEYCLOAK_CONFIG = {
8+
namespace: "rhdh-keycloak",
9+
releaseName: "keycloak",
10+
adminUser: "admin",
11+
adminPassword: "admin123",
12+
realm: "rhdh",
13+
};
14+
15+
export const DEFAULT_CONFIG_PATHS = {
16+
valuesFile: path.join(
17+
PACKAGE_ROOT,
18+
"dist/deployment/keycloak/config/keycloak-values.yaml",
19+
),
20+
};
21+
22+
export const BITNAMI_CHART_REPO = "https://charts.bitnami.com/bitnami";
23+
export const BITNAMI_CHART_NAME = "bitnami/keycloak";
24+
25+
export const DEFAULT_RHDH_CLIENT: KeycloakClientConfig = {
26+
clientId: "rhdh-client",
27+
clientSecret: "rhdh-client-secret",
28+
name: "RHDH Client",
29+
redirectUris: ["*"],
30+
webOrigins: ["*"],
31+
standardFlowEnabled: true,
32+
implicitFlowEnabled: true,
33+
directAccessGrantsEnabled: true,
34+
serviceAccountsEnabled: true,
35+
authorizationServicesEnabled: true,
36+
publicClient: false,
37+
defaultClientScopes: [
38+
"service_account",
39+
"web-origins",
40+
"roles",
41+
"profile",
42+
"basic",
43+
"email",
44+
],
45+
optionalClientScopes: [
46+
"address",
47+
"phone",
48+
"offline_access",
49+
"microprofile-jwt",
50+
],
51+
};
52+
53+
export const DEFAULT_GROUPS = [
54+
{ name: "developers" },
55+
{ name: "admins" },
56+
{ name: "viewers" },
57+
];
58+
59+
export const DEFAULT_USERS = [
60+
{
61+
username: "test1",
62+
email: "test1@example.com",
63+
firstName: "Test",
64+
lastName: "User1",
65+
enabled: true,
66+
emailVerified: true,
67+
password: "test1@123",
68+
groups: ["developers"],
69+
},
70+
{
71+
username: "test2",
72+
email: "test2@example.com",
73+
firstName: "Test",
74+
lastName: "User2",
75+
enabled: true,
76+
emailVerified: true,
77+
password: "test2@123",
78+
groups: ["developers"],
79+
},
80+
];
81+
82+
// Service account roles required for RHDH integration
83+
export const SERVICE_ACCOUNT_ROLES = [
84+
"view-authorization",
85+
"manage-authorization",
86+
"view-users",
87+
];

0 commit comments

Comments
 (0)