Repository navigation
Enable SPIRE in Keycloak - #238
Conversation
2e24cb9 to
67bbfef
Compare
|
To test, checkout this branch and the Kagenti branch (both named Follow the instructions in https://github.com/kagenti/kagenti-extensions/pull/238/changes#diff-2fbfbab126361511fee5f62d347944bf76c5ac003f078bb1c422e2dbc85f9e70 which will describe how to:
After the PR has been validated, I will remove the following files:
|
mrsabath
left a comment
There was a problem hiding this comment.
Good work on the SPIFFE/Keycloak federated JWT integration. The core changes to go-processor/main.go and client_registration.py are well-structured, and the webhook mutations (container_builder.go, pod_mutator.go) correctly inject env vars and fsGroup with proper defensive checks. The bulk realm rename from demo to kagenti is consistent.
One blocking issue: hardcoded developer path in the build script. Two additional suggestions below.
Also note: Two stale realms/demo references remain in commented-out lines:
AuthBridge/k8s/configmaps-webhook.yamlline 25AuthBridge/demos/webhook/k8s/configmaps-webhook.yamlline 38
Areas reviewed: Go, Python, Shell, YAML/K8s, Docs, Security
Commits: 12, all signed-off: yes
CI: All passing
mrsabath
left a comment
There was a problem hiding this comment.
Review Summary (Follow-up)
Previous REQUEST_CHANGES issues all addressed:
- ✅ Hardcoded developer path → now uses
KAGENTI_DIRenv var with auto-detection - ✅ Stale help text
(default: demo)→ updated to(default: kagenti) - ✅ Stale
realms/demoreferences → all cleaned up
New observations
suggestion: DEFAULT_OUTBOUND_POLICY validation was removed (line ~776 of main.go). The old code validated "exchange" or "passthrough" and warned on unknown values. The new code accepts any string — a typo like exchnage would silently break routing. Consider restoring the validation.
praise: Webhook changes are well-done:
container_builder.go: SPIFFE env vars injected fromauthbridge-configConfigMap withOptional: ptr.To(true)— won't break non-SPIFFE podspod_mutator.go:ensureFSGroup()is defensive — checks nil SecurityContext and only sets if not already presentclient_registration.py:derive_keycloak_config_from_token_url()is a clean backward-compat helper
nit: getConfig() now returns 7 values — consider returning the Config struct (or a copy) instead. Not blocking.
Areas reviewed: Go (AuthProxy + webhook), Python, Shell, K8s YAML, Docs, Security
Commits: 14, all signed-off
CI status: 17/17 passing
LGTM — SPIFFE federated JWT is a solid addition with proper feature gating.
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Updated LOCAL_TESTING_GUIDE.md to: - Add prominent warning to use ./local-build-and-test.sh script - Clarify that script builds from both kagenti and kagenti-extensions repos - Add "Common Mistakes to Avoid" section - Add comprehensive troubleshooting section for: - ErrImageNeverPull errors - RBAC permission issues - Token exchange failures - Client configuration problems Added FEDERATED_JWT_FIXES.md documenting: - All issues found during federated-jwt testing - Manual fixes applied during testing - Required changes to charts and scripts - Current status of each fix (done, missing, to verify) These docs prevent users from making the same mistakes and provide clear troubleshooting paths when issues occur. Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
ge-config Signed-off-by: Alan Cha <[email protected]>
The test deployment in LOCAL_TESTING_GUIDE.md was missing the shared-data volume and /shared mount that client-registration needs to write client-secret.txt. This caused an error: Error writing secret to file: [Errno 2] No such file or directory: '/shared/client-secret.txt' Changes: - Add shared-data emptyDir volume - Mount at /shared in client-registration container (read-write) - Mount at /shared in tools container (read-only) Now matches the volume structure injected by the webhook's container_builder.go (svid-output at /opt, shared-data at /shared). Signed-off-by: Alan Cha <[email protected]>
6b83be9 to
ad56660
Compare
After merging actor token support with JWT-SVID reload functionality, exchangeToken now requires 9 parameters instead of 7: - Added: spireEnabled (bool) - Added: jwtSvidPath (string) Updated test calls to pass false/empty for these new parameters since the actor token tests don't use SPIRE JWT-SVID authentication. Fixes CI error: not enough arguments in call to exchangeToken have (string, string, string, string, string, string, string) want (string, string, string, string, string, string, bool, string, string) Signed-off-by: Alan Cha <[email protected]>
Address code review feedback: 1. Add DEFAULT_OUTBOUND_POLICY validation (suggestion) - Now validates "exchange" or "passthrough" - Invalid values fallback to "passthrough" with warning - Prevents silent failures from typos like "exchnage" 2. Refactor getConfig() to return struct (nit) - Changed from returning 7 individual values to Config struct - Improves readability and maintainability - Easier to extend in the future Changes: - main.go:247-256: getConfig() now returns Config struct - main.go:636-743: Updated call sites to use config.Field syntax - main.go:824-837: Updated inbound JWT validation setup - main.go:852-859: Added DEFAULT_OUTBOUND_POLICY validation All tests passing. Signed-off-by: Alan Cha <[email protected]>
Exclude JWT rotation test script from version control. The script is useful for local testing but not intended to be checked in. Signed-off-by: Alan Cha <[email protected]>
b9229df to
934caf1
Compare
|
Apologies for the bit of tangled history (i.e., merging main into the current branch). I fell for the "fix in web" trick 😅 Merging as one of the action items for weekly report |
Enable SPIFFE/Keycloak Federated JWT Authentication
Fixes #82
Replaces #187
Replaces #159
This PR enables AuthBridge workloads to authenticate to Keycloak using SPIFFE JWT-SVIDs instead of traditional client secrets, enabling true zero-trust workload identity.
Changes
Core SPIFFE Integration
client-registration: Add
CLIENT_AUTH_TYPEsupport forfederated-jwtauthentication modeCLIENT_AUTH_TYPEenv var (client-secretorfederated-jwt)SPIFFE_IDP_ALIASandJWT_AUDIENCEconfigurationgo-processor: Enable SPIFFE JWT-SVID support for token exchange
/opt/jwt_svid.tokencontainer-builder: Inject SPIFFE configuration env vars
CLIENT_AUTH_TYPE- authentication mode selectionSPIFFE_IDP_ALIAS- Keycloak IdP alias for SPIFFE validationJWT_AUDIENCE- expected audience for JWT-SVID validationShared Volume Access
fsGroup: 1000on pod security contextTesting & Documentation
verify-spire-keycloak.sh,local-build-and-test.sh)LOCAL_TESTING_GUIDE.md)Architecture
SPIFFE Authentication Flow:
spiffe-helper→ writes JWT-SVID to/opt/jwt_svid.tokenclient-registration→ reads JWT-SVID, authenticates to Keycloak using federated-jwtenvoy-proxy→ performs token exchange using JWT-SVID credentialsfsGroup: 1000→ enables all containers to share the JWT-SVID fileRelated PRs
Testing
Tested locally with SPIRE and Keycloak using the provided test scripts. Verified: