Skip to content

feat: align kagenti with kagenti-extensions go-spiffe SDK migration - #1653

Merged
huang195 merged 2 commits into
rossoctl:mainfrom
huang195:feat/spiffe-jwt-audience-rendering
May 23, 2026
Merged

huang195 merged 2 commits into
rossoctl:mainfrom
huang195:feat/spiffe-jwt-audience-rendering

Conversation

@huang195

Copy link
Copy Markdown
Member

Companion to kagenti-extensions#432.

Why

The new authbridge image (PR #432) replaces the bundled spiffe-helper binary with an in-process go-spiffe SDK integration. That changes the authbridge config schema in two ways:

  • A top-level spiffe: block signals the framework to build the in-process Provider (X.509 source for mTLS + lazy JWT source for tokenexchange).
  • A per-plugin tokenexchange.identity.jwt_audience field carries the JWT-SVID client-assertion audience that previously lived in helper.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:

Source What changed
charts/kagenti/templates/authbridge-template-configmaps.yaml and charts/kagenti/templates/agent-namespaces.yaml Render spiffe: {} (when spire.enabled=true) and tokenexchange.identity.jwt_audience (when clientAuthType=federated-jwt). Drop the unused JWT_AUDIENCE env var from authbridge-config ConfigMap.
kagenti/backend/app/routers/agents.py (_build_authbridge_runtime_yaml) + tests Same schema change for backend-API-created agents.
kagenti/ui-v2/src/types/index.ts (IdentityConfig) Add optional jwt_audience field for type-safety in the UI form/validation surface.

Sequencing / backward compatibility

This PR is safe to land before kagenti-extensions#432:

  • New spiffe: block + jwt_audience field 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_AUDIENCE env 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-config ConfigMap and the legacy helper.conf rendering 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 -v passes
  • helm template charts/kagenti --set spire.enabled=true --set authBridge.clientAuthType=federated-jwt renders spiffe: {} and tokenexchange.identity.jwt_audience in both agent-namespaces.yaml and authbridge-template-configmaps.yaml outputs
  • helm template charts/kagenti --set spire.enabled=true --set authBridge.clientAuthType=client-secret does NOT render jwt_audience (only type: client-secret)
  • helm template charts/kagenti --set spire.enabled=false does NOT render the top-level spiffe: block
  • Local Kind: deploy + chat with weather-agent in federated-jwt mode succeeds (verified)

Assisted-By: Claude Code

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 pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@huang195
huang195 merged commit dd2642a into rossoctl:main May 23, 2026
23 checks passed
@huang195
huang195 deleted the feat/spiffe-jwt-audience-rendering branch May 23, 2026 12:04
@github-project-automation github-project-automation Bot moved this from New /:ToDo to Done in Rossoctl Issue Prioritization May 23, 2026
eranra pushed a commit to eranra/kagenti that referenced this pull request May 24, 2026
- 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]>
eranra pushed a commit to eranra/kagenti that referenced this pull request May 24, 2026
…ce-rendering

feat: align kagenti with kagenti-extensions go-spiffe SDK migration
Signed-off-by: Eran Raichstein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants