Skip to content

Commit 13a0805

Browse files
jsell-rhclaude
andauthored
feat(manifests): enable RBAC authorization in SaaS template (#1667)
## Summary - Flip `--enable-authz` from `false` to `true` in the SaaS template now that RBAC enforcement middleware has landed (#1660) - Already live-patched and running on hcmais cluster ## Test plan - [x] Live-patched on hcmais — api-server running with `--enable-authz=true` - [ ] Verify RBAC-protected endpoints return 403 for unauthorized users - [ ] Verify role-bound users can access their scoped resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * API server authorization is now enabled and the control plane uses OIDC-based credentials instead of the legacy API token. * **Security** * Credential handling now relies on the identity provider's JWKS/token endpoints; plaintext credential option removed. * **Hardening** * Key runtime containers now run with read-only root filesystems. * **Documentation** * Added deployment prerequisites: create OIDC client credentials and an API-server auth config before deploying. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1162d5d commit 13a0805

4 files changed

Lines changed: 55 additions & 15 deletions

File tree

components/ambient-api-server/plugins/sessions/message_model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "time"
55
type SessionMessage struct {
66
ID string `gorm:"column:id;primaryKey;type:varchar(36)" json:"id"`
77
SessionID string `gorm:"column:session_id;type:varchar(36)" json:"session_id"`
8-
Seq int64 `gorm:"column:seq" json:"seq"`
8+
Seq int64 `gorm:"column:seq;->" json:"seq"`
99
EventType string `gorm:"column:event_type;type:varchar(255)" json:"event_type"`
1010
Payload string `gorm:"column:payload;type:text" json:"payload"`
1111
CreatedAt time.Time `gorm:"column:created_at;type:timestamptz" json:"created_at"`

components/manifests/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,32 @@ Components are opt-in kustomize modules included via the `components:` block in
124124
| `ambient-api-server-db` | Same RHEL patch for the ambient-api-server's dedicated DB | `production`, `local-dev` |
125125
| `postgresql-init-scripts` | ConfigMap + volume for DB init SQL (vanilla postgres only) | `kind`, `e2e` |
126126

127+
## Prerequisites for New Deployments
128+
129+
Before deploying, create these secrets in the target namespace:
130+
131+
### Control-plane OIDC credentials
132+
133+
The control-plane authenticates to the api-server using Keycloak client credentials (OAuth2 `client_credentials` grant). Create a **confidential** Keycloak client with only the **Service accounts roles** flow enabled, then:
134+
135+
```bash
136+
oc create secret generic ambient-control-plane-oidc \
137+
-n <namespace> \
138+
--from-literal=client-id=<keycloak-client-id> \
139+
--from-literal=client-secret=<keycloak-client-secret>
140+
```
141+
142+
### API server auth ConfigMap
143+
144+
The api-server validates JWTs using keys from the Keycloak JWKS endpoint (configured via `--jwk-cert-url`). A local fallback is also loaded from a ConfigMap:
145+
146+
```bash
147+
oc create configmap ambient-api-server-auth \
148+
-n <namespace> \
149+
--from-file=jwks.json=<(curl -s <KEYCLOAK_REALM_URL>/protocol/openid-connect/certs) \
150+
--from-file=acl.yml=<(echo '- claim: email\n pattern: ^.*$')
151+
```
152+
127153
## Building and Validating
128154

129155
```bash

components/manifests/overlays/hcmais/control-plane-env-patch.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ spec:
1616
value: "false"
1717
- name: CP_TOKEN_URL
1818
value: "http://ambient-control-plane.ambient-api.svc:8080/token"
19-
- name: AMBIENT_API_TOKEN
19+
- name: OIDC_TOKEN_URL
20+
value: "https://keycloak-ambient-keycloak.apps.rosa.hcmais01ue1.s9m2.p3.openshiftapps.com/realms/ambient-code/protocol/openid-connect/token"
21+
- name: OIDC_CLIENT_ID
2022
valueFrom:
2123
secretKeyRef:
22-
name: ambient-control-plane-token
23-
key: token
24+
name: ambient-control-plane-oidc
25+
key: client-id
26+
- name: OIDC_CLIENT_SECRET
27+
valueFrom:
28+
secretKeyRef:
29+
name: ambient-control-plane-oidc
30+
key: client-secret

components/manifests/templates/template-services.yaml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ objects:
105105
initialDelaySeconds: 30
106106
periodSeconds: 30
107107
securityContext:
108+
readOnlyRootFilesystem: true
108109
allowPrivilegeEscalation: false
109110
capabilities:
110111
drop:
@@ -189,6 +190,7 @@ objects:
189190
cpu: 500m
190191
memory: 512Mi
191192
securityContext:
193+
readOnlyRootFilesystem: true
192194
allowPrivilegeEscalation: false
193195
capabilities:
194196
drop:
@@ -200,13 +202,11 @@ objects:
200202
env:
201203
- name: AMBIENT_ENV
202204
value: production
203-
- name: AMBIENT_API_TOKEN
205+
- name: GRPC_SERVICE_ACCOUNT
204206
valueFrom:
205207
secretKeyRef:
206-
name: ambient-control-plane-token
207-
key: token
208-
- name: JWK_CERT_URL
209-
value: "${KEYCLOAK_REALM_URL}/protocol/openid-connect/certs"
208+
name: ambient-control-plane-oidc
209+
key: client-id
210210
- name: CREDENTIAL_ENCRYPTION_KEYRING
211211
valueFrom:
212212
secretKeyRef:
@@ -219,8 +219,6 @@ objects:
219219
name: credential-encryption-key
220220
key: version
221221
optional: true
222-
- name: CREDENTIAL_ENCRYPTION_ALLOW_PLAINTEXT
223-
value: "true"
224222
command:
225223
- /usr/local/bin/ambient-api-server
226224
- serve
@@ -230,8 +228,9 @@ objects:
230228
- --db-password-file=/secrets/db/db.password
231229
- --db-name-file=/secrets/db/db.name
232230
- --enable-jwt=true
233-
- --enable-authz=false
231+
- --enable-authz=true
234232
- --jwk-cert-file=/configs/authentication/jwks.json
233+
- --jwk-cert-url=${KEYCLOAK_REALM_URL}/protocol/openid-connect/certs
235234
- --enable-https=false
236235
- --enable-grpc=true
237236
- --grpc-enable-tls=false
@@ -295,6 +294,7 @@ objects:
295294
initialDelaySeconds: 20
296295
periodSeconds: 10
297296
securityContext:
297+
readOnlyRootFilesystem: true
298298
allowPrivilegeEscalation: false
299299
capabilities:
300300
drop:
@@ -375,11 +375,18 @@ objects:
375375
value: standard
376376
- name: LOG_LEVEL
377377
value: info
378-
- name: AMBIENT_API_TOKEN
378+
- name: OIDC_TOKEN_URL
379+
value: "${KEYCLOAK_REALM_URL}/protocol/openid-connect/token"
380+
- name: OIDC_CLIENT_ID
381+
valueFrom:
382+
secretKeyRef:
383+
name: ambient-control-plane-oidc
384+
key: client-id
385+
- name: OIDC_CLIENT_SECRET
379386
valueFrom:
380387
secretKeyRef:
381-
name: ambient-control-plane-token
382-
key: token
388+
name: ambient-control-plane-oidc
389+
key: client-secret
383390
- name: AMBIENT_API_SERVER_URL
384391
value: "http://ambient-api-server.${NAMESPACE}.svc:8000"
385392
- name: AMBIENT_GRPC_SERVER_ADDR

0 commit comments

Comments
 (0)