@aifabrix/builder 2.1.4 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/templates.js
CHANGED
|
@@ -128,7 +128,10 @@ function buildDatabaseEnv(config) {
|
|
|
128
128
|
'DB_PORT': '5432',
|
|
129
129
|
'DB_NAME': dbName,
|
|
130
130
|
'DB_USER': `${dbName}_user`,
|
|
131
|
-
'DB_PASSWORD': `kv://databases-${appName}-0-passwordKeyVault
|
|
131
|
+
'DB_PASSWORD': `kv://databases-${appName}-0-passwordKeyVault`,
|
|
132
|
+
// Also include DB_0_PASSWORD for compatibility with compose generator
|
|
133
|
+
// (compose generator expects DB_0_PASSWORD when databases array is present)
|
|
134
|
+
'DB_0_PASSWORD': `kv://databases-${appName}-0-passwordKeyVault`
|
|
132
135
|
};
|
|
133
136
|
}
|
|
134
137
|
|
|
@@ -21,16 +21,32 @@ handlebars.registerHelper('pgQuote', (identifier) => {
|
|
|
21
21
|
return '';
|
|
22
22
|
}
|
|
23
23
|
// Always quote identifiers to handle hyphens and special characters
|
|
24
|
-
|
|
24
|
+
// Return SafeString to prevent HTML escaping
|
|
25
|
+
return new handlebars.SafeString(`"${String(identifier).replace(/"/g, '""')}"`);
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
// Helper to generate quoted PostgreSQL user name from database name
|
|
29
|
+
// User names must use underscores (not hyphens) for PostgreSQL compatibility
|
|
28
30
|
handlebars.registerHelper('pgUser', (dbName) => {
|
|
29
31
|
if (!dbName) {
|
|
30
32
|
return '';
|
|
31
33
|
}
|
|
34
|
+
// Replace hyphens with underscores in user name (database names can have hyphens, but user names should not)
|
|
35
|
+
const userName = `${String(dbName).replace(/-/g, '_')}_user`;
|
|
36
|
+
// Return SafeString to prevent HTML escaping
|
|
37
|
+
return new handlebars.SafeString(`"${userName.replace(/"/g, '""')}"`);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Helper to generate old user name format (for migration - drops old users with hyphens)
|
|
41
|
+
// This is used to drop legacy users that were created with hyphens before the fix
|
|
42
|
+
handlebars.registerHelper('pgUserOld', (dbName) => {
|
|
43
|
+
if (!dbName) {
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
// Old format: database name + _user (preserving hyphens)
|
|
32
47
|
const userName = `${String(dbName)}_user`;
|
|
33
|
-
|
|
48
|
+
// Return SafeString to prevent HTML escaping
|
|
49
|
+
return new handlebars.SafeString(`"${userName.replace(/"/g, '""')}"`);
|
|
34
50
|
});
|
|
35
51
|
|
|
36
52
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Keycloak Identity and Access Management with Custom Themes
|
|
2
|
-
# This Dockerfile extends Keycloak
|
|
2
|
+
# This Dockerfile extends Keycloak 26.4 with custom themes
|
|
3
3
|
|
|
4
|
-
FROM quay.io/keycloak/keycloak:
|
|
4
|
+
FROM quay.io/keycloak/keycloak:26.4
|
|
5
5
|
|
|
6
6
|
# Set working directory
|
|
7
7
|
WORKDIR /opt/keycloak
|
|
@@ -70,18 +70,20 @@ services:
|
|
|
70
70
|
{{#each databases}}
|
|
71
71
|
echo 'Creating {{name}} database and user...' &&
|
|
72
72
|
(psql -d postgres -c \"CREATE DATABASE \\\"{{name}}\\\";\" || true) &&
|
|
73
|
-
(psql -d postgres -c \"
|
|
74
|
-
psql -d postgres -c \"
|
|
75
|
-
psql -d
|
|
76
|
-
psql -d {{name}} -c \"
|
|
73
|
+
(psql -d postgres -c \"DROP USER IF EXISTS {{pgUserOld name}};\" || true) &&
|
|
74
|
+
(psql -d postgres -c \"CREATE USER {{pgUser name}} WITH PASSWORD '${DB_{{@index}}_PASSWORD}';\" || true) &&
|
|
75
|
+
psql -d postgres -c \"GRANT ALL PRIVILEGES ON DATABASE \\\"{{name}}\\\" TO {{pgUser name}};\" || true &&
|
|
76
|
+
psql -d {{name}} -c \"ALTER SCHEMA public OWNER TO {{pgUser name}};\" || true &&
|
|
77
|
+
psql -d {{name}} -c \"GRANT ALL ON SCHEMA public TO {{pgUser name}};\" || true &&
|
|
77
78
|
{{/each}}
|
|
78
79
|
{{else}}
|
|
79
80
|
echo 'Creating {{app.key}} database and user...' &&
|
|
80
81
|
(psql -d postgres -c \"CREATE DATABASE \\\"{{app.key}}\\\";\" || true) &&
|
|
81
|
-
(psql -d postgres -c \"
|
|
82
|
-
psql -d postgres -c \"
|
|
83
|
-
psql -d
|
|
84
|
-
psql -d {{app.key}} -c \"
|
|
82
|
+
(psql -d postgres -c \"DROP USER IF EXISTS {{pgUserOld app.key}};\" || true) &&
|
|
83
|
+
(psql -d postgres -c \"CREATE USER {{pgUser app.key}} WITH PASSWORD '${DB_0_PASSWORD:-${DB_PASSWORD}}';\" || true) &&
|
|
84
|
+
psql -d postgres -c \"GRANT ALL PRIVILEGES ON DATABASE \\\"{{app.key}}\\\" TO {{pgUser app.key}};\" || true &&
|
|
85
|
+
psql -d {{app.key}} -c \"ALTER SCHEMA public OWNER TO {{pgUser app.key}};\" || true &&
|
|
86
|
+
psql -d {{app.key}} -c \"GRANT ALL ON SCHEMA public TO {{pgUser app.key}};\" || true &&
|
|
85
87
|
{{/if}}
|
|
86
88
|
echo 'Database initialization complete!'
|
|
87
89
|
"
|
|
@@ -70,18 +70,20 @@ services:
|
|
|
70
70
|
{{#each databases}}
|
|
71
71
|
echo 'Creating {{name}} database and user...' &&
|
|
72
72
|
(psql -d postgres -c \"CREATE DATABASE \\\"{{name}}\\\";\" || true) &&
|
|
73
|
-
(psql -d postgres -c \"
|
|
74
|
-
psql -d postgres -c \"
|
|
75
|
-
psql -d
|
|
76
|
-
psql -d {{name}} -c \"
|
|
73
|
+
(psql -d postgres -c \"DROP USER IF EXISTS {{pgUserOld name}};\" || true) &&
|
|
74
|
+
(psql -d postgres -c \"CREATE USER {{pgUser name}} WITH PASSWORD '${DB_{{@index}}_PASSWORD}';\" || true) &&
|
|
75
|
+
psql -d postgres -c \"GRANT ALL PRIVILEGES ON DATABASE \\\"{{name}}\\\" TO {{pgUser name}};\" || true &&
|
|
76
|
+
psql -d {{name}} -c \"ALTER SCHEMA public OWNER TO {{pgUser name}};\" || true &&
|
|
77
|
+
psql -d {{name}} -c \"GRANT ALL ON SCHEMA public TO {{pgUser name}};\" || true &&
|
|
77
78
|
{{/each}}
|
|
78
79
|
{{else}}
|
|
79
80
|
echo 'Creating {{app.key}} database and user...' &&
|
|
80
81
|
(psql -d postgres -c \"CREATE DATABASE \\\"{{app.key}}\\\";\" || true) &&
|
|
81
|
-
(psql -d postgres -c \"
|
|
82
|
-
psql -d postgres -c \"
|
|
83
|
-
psql -d
|
|
84
|
-
psql -d {{app.key}} -c \"
|
|
82
|
+
(psql -d postgres -c \"DROP USER IF EXISTS {{pgUserOld app.key}};\" || true) &&
|
|
83
|
+
(psql -d postgres -c \"CREATE USER {{pgUser app.key}} WITH PASSWORD '${DB_0_PASSWORD:-${DB_PASSWORD}}';\" || true) &&
|
|
84
|
+
psql -d postgres -c \"GRANT ALL PRIVILEGES ON DATABASE \\\"{{app.key}}\\\" TO {{pgUser app.key}};\" || true &&
|
|
85
|
+
psql -d {{app.key}} -c \"ALTER SCHEMA public OWNER TO {{pgUser app.key}};\" || true &&
|
|
86
|
+
psql -d {{app.key}} -c \"GRANT ALL ON SCHEMA public TO {{pgUser app.key}};\" || true &&
|
|
85
87
|
{{/if}}
|
|
86
88
|
echo 'Database initialization complete!'
|
|
87
89
|
"
|