Repository navigation
feat: align kagenti with kagenti-extensions go-spiffe SDK migration - #1653
Conversation
Companion to kagenti-extensions PR rossoctl#432, which replaces the bundled spiffe-helper binary with an in-process go-spiffe SDK integration. The new authbridge image expects two schema changes: * a top-level `spiffe:` block (empty mapping when SPIRE is enabled) that signals the framework to construct the in-process Provider (X.509 source for mTLS + lazy JWT source for tokenexchange); * a per-plugin `tokenexchange.identity.jwt_audience` field carrying the JWT-SVID client-assertion audience (replaces the audience that spiffe-helper previously baked into helper.conf). Updates the two places kagenti emits authbridge config so both Helm- installed and backend-API-created agents render the new shape: * charts/kagenti/templates/{authbridge-template-configmaps, agent-namespaces}.yaml — render the spiffe block + jwt_audience. JWT_AUDIENCE env var (dead code; nothing reads it) dropped from authbridge-config ConfigMap. * kagenti/backend/app/routers/agents.py:_build_authbridge_runtime_yaml and the matching tests — same shape change for backend-rendered ConfigMaps. Adds the optional `jwt_audience` field on the UI's IdentityConfig type so the form/validation surface stays in sync. Backward compatibility with the OLD authbridge image (during rollout): both schema changes are additive — the old image's YAML decoder silently drops unknown keys, so deployments running the old image keep working with the new chart. spiffe-helper-config ConfigMap and the helper.conf rendering are intentionally left in place; they are no-ops against the new image and required by the old one. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
- Chart: add `kagenti.authBridge.validateSpiffeIdentity` helper that
fails fast at helm template time when authBridge.clientAuthType=
federated-jwt is set without spire.enabled=true. Without the guard,
the chart silently emits identity.type=spiffe + jwt_audience but
no top-level spiffe block, and the new authbridge image
CrashLoopBackOffs with "spiffe identity requires a SPIFFE provider
to be injected". Helper is invoked from both authbridge-template-
configmaps.yaml and agent-namespaces.yaml.
- Backend test: drop the dead `or cfg["spiffe"] is None` disjunct;
yaml.safe_load on `spiffe: {}` always returns the empty dict, so
the None branch was unreachable.
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
pdettori
left a comment
There was a problem hiding this comment.
Clean, well-structured PR. Config schema changes are consistent across all three paths (Helm agent-namespaces, Helm authbridge-template-configmaps, Python backend). The validation helper in _helpers.tpl provides good fail-fast behavior for misconfiguration. Tests cover both positive (spiffe + jwt_audience present) and negative (client-secret without jwt_audience) cases. CI fully green.
Areas reviewed: Helm/K8s, Python, TypeScript, Tests
| identity: dict[str, str] = {"type": identity_type} | ||
| if identity_type == "spiffe": | ||
| # JWT-SVID client-assertion audience — must match what Keycloak's | ||
| # SPIFFE IdP expects (the realm issuer URL). Required by |
There was a problem hiding this comment.
suggestion (non-blocking): The issuer param used as jwt_audience is semantically the Keycloak realm URL — consider renaming to jwt_audience at the function boundary for clarity, since it's not really an "issuer" in the OIDC sense when used as a SPIFFE JWT-SVID audience claim. Current code is correct either way.
- Chart: add `kagenti.authBridge.validateSpiffeIdentity` helper that
fails fast at helm template time when authBridge.clientAuthType=
federated-jwt is set without spire.enabled=true. Without the guard,
the chart silently emits identity.type=spiffe + jwt_audience but
no top-level spiffe block, and the new authbridge image
CrashLoopBackOffs with "spiffe identity requires a SPIFFE provider
to be injected". Helper is invoked from both authbridge-template-
configmaps.yaml and agent-namespaces.yaml.
- Backend test: drop the dead `or cfg["spiffe"] is None` disjunct;
yaml.safe_load on `spiffe: {}` always returns the empty dict, so
the None branch was unreachable.
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Hai Huang <[email protected]>
Signed-off-by: Eran Raichstein <[email protected]>
…ce-rendering feat: align kagenti with kagenti-extensions go-spiffe SDK migration Signed-off-by: Eran Raichstein <[email protected]>
Companion to kagenti-extensions#432.
Why
The new authbridge image (PR #432) replaces the bundled
spiffe-helperbinary with an in-processgo-spiffeSDK integration. That changes the authbridge config schema in two ways:spiffe:block signals the framework to build the in-process Provider (X.509 source for mTLS + lazy JWT source for tokenexchange).tokenexchange.identity.jwt_audiencefield carries the JWT-SVID client-assertion audience that previously lived inhelper.conf.Without these chart updates, the new image fails to boot in SPIRE-enabled deployments — either skipping Provider construction (no mTLS, spiffe identity unwired) or failing Configure with
identity.type=spiffe requires identity.jwt_audience to be set.What
Two code paths emit authbridge config in this repo. Both are updated:
charts/kagenti/templates/authbridge-template-configmaps.yamlandcharts/kagenti/templates/agent-namespaces.yamlspiffe: {}(whenspire.enabled=true) andtokenexchange.identity.jwt_audience(whenclientAuthType=federated-jwt). Drop the unusedJWT_AUDIENCEenv var fromauthbridge-configConfigMap.kagenti/backend/app/routers/agents.py(_build_authbridge_runtime_yaml) + testskagenti/ui-v2/src/types/index.ts(IdentityConfig)jwt_audiencefield for type-safety in the UI form/validation surface.Sequencing / backward compatibility
This PR is safe to land before kagenti-extensions#432:
spiffe:block +jwt_audiencefield are additive. The OLD authbridge image's YAML decoder silently drops unknown keys, so deployments still running the old image keep working with the updated chart.JWT_AUDIENCEenv var being removed has no consumer (verified across kagenti, kagenti-extensions, and kagenti-operator — only the operator parsed it into a struct field that nothing reads). Old image unaffected.spiffe-helper-configConfigMap and the legacyhelper.confrendering are intentionally LEFT in place. They're no-ops against the new image (no spiffe-helper binary to read them) and required by the old image during a phased rollout. Cleanup can land in a follow-up PR after all old-image deployments are gone.Test plan
cd kagenti/backend && uv run pytest tests/test_authbridge_runtime_config.py -vpasseshelm template charts/kagenti --set spire.enabled=true --set authBridge.clientAuthType=federated-jwtrendersspiffe: {}andtokenexchange.identity.jwt_audiencein bothagent-namespaces.yamlandauthbridge-template-configmaps.yamloutputshelm template charts/kagenti --set spire.enabled=true --set authBridge.clientAuthType=client-secretdoes NOT renderjwt_audience(onlytype: client-secret)helm template charts/kagenti --set spire.enabled=falsedoes NOT render the top-levelspiffe:blockAssisted-By: Claude Code