Skip to content

Commit a25559f

Browse files
Copilotphrocker
andcommitted
Complete secret removal - fix template validation and add documentation
Co-authored-by: phrocker <[email protected]>
1 parent 677e77c commit a25559f

File tree

7 files changed

+109
-23
lines changed

7 files changed

+109
-23
lines changed

ai-agent/src/main/resources/challenger.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ server.error.whitelabel.enabled=false
4646
keycloak.realm=sentrius
4747
keycloak.base-url=${KEYCLOAK_BASE_URL:http://localhost:8180}
4848
spring.security.oauth2.client.registration.keycloak.client-id=ai-agents-assessor
49-
spring.security.oauth2.client.registration.keycloak.client-secret=e4WgJovH8MzcAvRnFg3rROAbeDIwiYmy
49+
spring.security.oauth2.client.registration.keycloak.client-secret=${KEYCLOAK_CLIENT_SECRET:}
5050
spring.security.oauth2.client.registration.keycloak.authorization-grant-type=client_credentials
5151
spring.security.oauth2.client.registration.keycloak.redirect-uri=http://192.168.1.162:8080/login/oauth2/code/keycloak
5252
spring.security.oauth2.client.registration.keycloak.scope=openid,profile,email

docker/keycloak/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Keycloak Realm Configuration
2+
3+
This realm configuration file contains client definitions for Sentrius.
4+
5+
⚠️ **IMPORTANT**: The client secrets in this file are set to "CHANGE_ME_AFTER_IMPORT" and must be updated after importing the realm to match the secrets configured in your Helm deployment.
6+
7+
The client secrets should be configured to match:
8+
- The OAuth2 secrets generated by the Helm chart
9+
- Or the secrets you provide in your values.yaml
10+
11+
You can update client secrets via:
12+
1. Keycloak Admin Console
13+
2. Keycloak Admin REST API
14+
3. Environment variable substitution during realm import

docker/keycloak/realms/sentrius-realm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"clientId": "sentrius-api",
77
"enabled": true,
88
"clientAuthenticatorType": "client-secret",
9-
"secret": "nGkEukexSWTvDzYjSkDmeUlM0FJ5Jhh0",
9+
"secret": "CHANGE_ME_AFTER_IMPORT",
1010
"rootUrl": "${ROOT_URL}",
1111
"baseUrl": "${ROOT_URL}",
1212
"serviceAccountsEnabled": true,
@@ -40,7 +40,7 @@
4040
"clientId": "sentrius-launcher-service",
4141
"enabled": true,
4242
"clientAuthenticatorType": "client-secret",
43-
"secret": "nGkEukexSWTSjklj3sddgvDzYjSkDmeUlM0FJ5Jhh0",
43+
"secret": "CHANGE_ME_AFTER_IMPORT",
4444
"rootUrl": "${ROOT_URL}",
4545
"baseUrl": "${ROOT_URL}",
4646

@@ -81,7 +81,7 @@
8181
"enabled": true,
8282
"alwaysDisplayInConsole": false,
8383
"clientAuthenticatorType": "client-secret",
84-
"secret": "e4WgJovH8MzcAvRnFg3rROAbeDIwiYmx",
84+
"secret": "CHANGE_ME_AFTER_IMPORT",
8585
"redirectUris": [
8686
"${REDIRECT_URIS}/*"
8787
],
@@ -168,7 +168,7 @@
168168
"enabled": true,
169169
"alwaysDisplayInConsole": false,
170170
"clientAuthenticatorType": "client-secret",
171-
"secret": "e4WgJovH8MzcAvRnFg3rROAbeDIwiYmy",
171+
"secret": "CHANGE_ME_AFTER_IMPORT",
172172
"redirectUris": [
173173
"${REDIRECT_URIS}/*"
174174
],

docs/secret-management.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Sentrius Secret Management
2+
3+
## Overview
4+
5+
Hardcoded secrets have been removed from the Helm charts and application properties files. The system now supports both dynamic secret generation and external secret management.
6+
7+
## Dynamic Secret Generation
8+
9+
When no secrets are provided in values.yaml, the Helm charts will automatically generate random secrets for:
10+
11+
- OAuth2 client secrets (32 characters)
12+
- Database passwords (32 characters)
13+
- Keystore passwords (24 characters)
14+
- Keycloak admin passwords (24 characters)
15+
- Neo4j authentication strings (16 character passwords)
16+
17+
## Providing Custom Secrets
18+
19+
You can override the generated secrets by setting them in your values.yaml:
20+
21+
```yaml
22+
# Example custom secrets
23+
secrets:
24+
db:
25+
username: "my-db-user"
26+
password: "my-secure-password"
27+
keystorePassword: "my-keystore-password"
28+
29+
sentrius:
30+
oauth2:
31+
client_secret: "my-oauth2-secret"
32+
33+
keycloak:
34+
adminPassword: "my-keycloak-admin-password"
35+
clientSecret: "my-keycloak-client-secret"
36+
db:
37+
password: "my-keycloak-db-password"
38+
39+
neo4j:
40+
env:
41+
NEO4J_AUTH: "neo4j/my-neo4j-password"
42+
```
43+
44+
## Environment Variables
45+
46+
Application properties files now use environment variables with fallback defaults:
47+
48+
- `KEYCLOAK_CLIENT_SECRET` - OAuth2 client secret for Keycloak
49+
- `DATABASE_PASSWORD` - Database password (defaults to "password")
50+
- `KEYSTORE_PASSWORD` - Keystore password (defaults to "keystorepassword")
51+
52+
## Production Deployment
53+
54+
For production environments, it is recommended to:
55+
56+
1. Use an external secret management system (HashiCorp Vault, AWS Secrets Manager, etc.)
57+
2. Set all secrets explicitly in your values.yaml file
58+
3. Use Kubernetes secrets or external secret operators
59+
4. Never commit secrets to version control
60+
61+
## Removed Hardcoded Secrets
62+
63+
The following hardcoded secrets were removed:
64+
65+
- `nGkEukexSWTvDzYjSkDmeUlM0FJ5Jhh0` (multiple OAuth2 client secrets)
66+
- `e4WgJovH8MzcAvRnFg3rROAbeDIwiYmx` (agent client secret)
67+
- `KLJMLKSDJGlkj23@#jasdlkjg@#dsagsagdsag` (AI agent client secret)
68+
- `neo4j/testingsecret` (Neo4j authentication)
69+
- Base64 encoded database credentials
70+
- Hardcoded keystore passwords

sentrius-chart/templates/ingress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
name: {{ .Release.Name }}-keycloak
1919
port:
2020
number: 8081
21-
- host: {{ .Values.subdomain }}
21+
- host: {{ .Values.tenant }}.sentrius.cloud
2222
http:
2323
paths:
2424
- path: /

sentrius-chart/templates/keycloak-deployment.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,35 @@ spec:
1010
selector:
1111
matchLabels:
1212
app: keycloak
13-
release: {{ .Release.Name }}
1413
template:
1514
metadata:
1615
labels:
1716
app: keycloak
18-
release: {{ .Release.Name }}
1917
spec:
18+
initContainers:
19+
- name: wait-for-keycloak-db
20+
image: busybox
21+
command: ['sh', '-c', 'until nc -z keycloak-db 5432; do echo waiting for keycloak-db; sleep 2; done;']
2022
containers:
2123
- name: keycloak
2224
image: "{{ .Values.keycloak.image.repository }}:{{ .Values.keycloak.image.tag }}"
2325
imagePullPolicy: "{{ .Values.keycloak.image.pullPolicy }}"
2426
ports:
25-
- containerPort: 8081
26-
{{- if not (eq .Values.environment "gke") }}
27+
- containerPort: {{ .Values.keycloak.port }}
2728
readinessProbe:
2829
httpGet:
2930
path: {{ .Values.healthCheck.keycloak.readinessPath }}
30-
port: {{ .Values.healthCheck.keycloak.port }}
31-
initialDelaySeconds: 5
31+
port: {{ .Values.keycloak.port }}
32+
initialDelaySeconds: 30
3233
periodSeconds: 10
34+
timeoutSeconds: 5
3335
livenessProbe:
3436
httpGet:
3537
path: {{ .Values.healthCheck.keycloak.livenessPath }}
36-
port: {{ .Values.healthCheck.keycloak.port }}
37-
initialDelaySeconds: 5
38+
port: {{ .Values.keycloak.port }}
39+
initialDelaySeconds: 60
3840
periodSeconds: 10
39-
{{- end }}
41+
timeoutSeconds: 5
4042
env:
4143
- name: KC_HTTP_PORT
4244
value: "8081"
@@ -61,7 +63,7 @@ spec:
6163
name: {{ .Release.Name }}-keycloak-secrets
6264
key: db-password
6365
- name: KC_HOSTNAME
64-
value: {{ .Values.keycloakHostname }}
66+
value: "keycloak.{{ .Values.tenant }}.sentrius.cloud"
6567
- name: KC_HOSTNAME_STRICT
6668
value: "false"
6769
- name: KEYCLOAK_LOGLEVEL
@@ -85,5 +87,5 @@ spec:
8587
secretKeyRef:
8688
name: {{ .Release.Name }}-keycloak-secrets
8789
key: client-secret
88-
command: [ "/opt/keycloak/bin/kc.sh" ]
89-
args: [ "start-dev", "--proxy=edge", "--import-realm", "--health-enabled=true"]
90+
command: ["/opt/keycloak/bin/kc.sh"]
91+
args: ["start-dev", "--proxy=edge", "--import-realm", "--health-enabled=true"]

sentrius-chart/values.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ environment: "gke" # Can be "gke", "aws", "azure", "local"
66

77
tenant: sentrius-demo
88
subdomain: "{{ .Values.tenant }}.sentrius.cloud"
9-
keycloakSubdomain: keycloak.{{ .Values.subdomain }}
10-
keycloakHostname: "{{ .Values.keycloakSubdomain }}"
11-
keycloakDomain: https://{{ .Values.keycloakSubdomain }}
12-
sentriusDomain: https://{{ .Values.subdomain }}
9+
keycloakSubdomain: "keycloak.{{ .Values.tenant }}.sentrius.cloud"
10+
keycloakHostname: "keycloak.{{ .Values.tenant }}.sentrius.cloud"
11+
keycloakDomain: "https://keycloak.{{ .Values.tenant }}.sentrius.cloud"
12+
sentriusDomain: "https://{{ .Values.tenant }}.sentrius.cloud"
1313
launcherFQDN: sentrius-launcher-service.dev.svc.cluster.local
1414

1515

@@ -203,7 +203,7 @@ keycloak:
203203
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
204204

205205
ingress:
206-
enabled: false # Temporarily disabled during secret refactoring
206+
enabled: true
207207
class: "nginx" # Default for local; override for GKE/AWS
208208
tlsEnabled: true # Enable TLS when supported
209209
annotations:

0 commit comments

Comments
 (0)