Skip to content

feat: Expose AuthBridge sidecar configuration options in Agent/Tool import UI #1167

Closed

Description

@mrsabath

Summary

Recent changes to kagenti-extensions have significantly expanded the AuthBridge configuration surface — combined sidecar mode (PR #254), operator-managed Keycloak client credentials with opt-in sidecar injection (PR #262) — but the Kagenti UI only exposes two coarse toggles (authBridgeEnabled, spireEnabled) in the Agent and Tool import flows. Users who need any configuration beyond all-or-nothing sidecar injection must hand-edit Kubernetes manifests.

This issue tracks the full set of UI gaps introduced by these changes and provides implementation-level guidance for closing them.

Related issues


Gap Analysis

Current UI state

UI Control Location Maps to
authBridgeEnabled checkbox (agents: ON, tools: OFF) ImportAgentPage.tsx, ImportToolPage.tsx kagenti.io/inject: "enabled"|"disabled" label
spireEnabled checkbox (default: OFF) Same kagenti.io/spire: "enabled" label

Backend label generation in agents.py:

KAGENTI_INJECT_LABEL: "enabled" if request.authBridgeEnabled else "disabled",

That is the entire AuthBridge configuration surface exposed to users. Everything below is missing.


Gap 1: Inaccurate UI description (bug — caused by PR #262)

Priority: High (correctness)

The checkbox description in both ImportAgentPage.tsx and ImportToolPage.tsx reads:

"When enabled, the webhook injects AuthBridge sidecars (envoy-proxy, go-processor, client-registration) into the agent pod for token exchange."

Since PR #262, client-registration is no longer injected by default. The operator manages Keycloak client credentials now. The sidecar is only injected when kagenti.io/client-registration-inject: "true" is explicitly set.

Fix: Update the description to reflect the current behavior:

"When enabled, the webhook injects AuthBridge sidecars (envoy-proxy, go-processor, spiffe-helper) into the pod for inbound JWT validation and outbound token exchange. Keycloak client registration is managed by the operator by default."


Gap 2: Per-sidecar injection controls (partially tracked in #836)

Priority: Medium

The webhook supports per-sidecar opt-out via pod template labels, but the UI has no controls for them.

Sidecar Label Default behavior
Envoy Proxy (+ proxy-init) kagenti.io/envoy-proxy-inject: "false" Inject
SPIFFE Helper kagenti.io/spiffe-helper-inject: "false" Inject
Client Registration (legacy sidecar) kagenti.io/client-registration-inject: "true" Skip (operator-managed is now default per PR #262)

UI change needed: When authBridgeEnabled is ON, show an expandable "Advanced Injection Controls" section with individual toggles:

  • Envoy Proxy — toggle (default: ON) — sets/removes kagenti.io/envoy-proxy-inject: "false"
  • SPIFFE Helper — toggle (default: ON) — sets/removes kagenti.io/spiffe-helper-inject: "false"
  • Legacy Client Registration Sidecar — toggle (default: OFF) — sets/removes kagenti.io/client-registration-inject: "true"
    • Helper text: "Enable only if you need sidecar-based client registration instead of operator-managed credentials."

Backend changes:

  • agents.py / tools.py: Add fields to CreateAgentRequest / CreateToolRequest:
    envoyProxyInject: Optional[bool] = None   # None = default (inject)
    spiffeHelperInject: Optional[bool] = None # None = default (inject)
    clientRegistrationInject: Optional[bool] = None  # None = default (skip)
  • _build_agent_labels(): Set the corresponding kagenti.io/*-inject labels based on these fields

Gap 3: Combined sidecar mode (new — PR #254)

Priority: Medium

PR #254 added a combinedSidecar feature gate that merges the three long-running sidecars (envoy-proxy, spiffe-helper, kagenti-client-registration) into a single authbridge container. This reduces per-pod overhead from 3 sidecars + 1 init to 1 sidecar + 1 init.

The feature is controlled by:

  1. Cluster-level: featureGates.combinedSidecar in the webhook Helm chart (default: false)
  2. There is no per-workload override — it is purely a cluster-wide gate today

UI change needed:

  • At minimum, add an informational indicator in the import flow: if the cluster has combinedSidecar: true, show a badge/note: "Combined sidecar mode is active — AuthBridge uses a single container."
  • Optionally, if the webhook is extended to support per-workload combined mode selection, expose a toggle.
  • The backend could query the webhook feature gate state via the kagenti-webhook-defaults ConfigMap in kagenti-webhook-system namespace.

Gap 4: Outbound token-exchange routing (authproxy-routes)

Priority: High (usability)

When AuthBridge is enabled, outbound traffic policy defaults to passthrough — no token exchange happens unless per-host routes are configured in the authproxy-routes ConfigMap. Currently there is no UI for managing these routes, which means:

  • Users deploy an agent with AuthBridge enabled
  • Outbound calls to tools/services pass through without tokens
  • Users must manually create/edit authproxy-routes ConfigMap with routes.yaml key

Route format (from go-processor/internal/resolver/static.go):

- host: "github-tool-mcp"
  target_audience: "github-tool-mcp"
  token_scopes: "read:issues write:issues"
- host: "weather-service"
  target_audience: "weather-service"
  passthrough: true

Each route has: host (glob pattern, typically short K8s service name), target_audience, token_scopes, optional token_url, optional passthrough.

UI change needed:

  • Add an "Outbound Routing Rules" section when AuthBridge is enabled
  • Provide a table/form to add routes: Host pattern, Target Audience, Token Scopes, Passthrough toggle
  • Backend creates/updates the authproxy-routes ConfigMap in the target namespace
  • Auto-populate: when a tool is already deployed in the same namespace, offer to auto-add a route for it

Gap 5: authbridge-config namespace parameters

Priority: Medium

The authbridge-config ConfigMap contains runtime configuration for the AuthBridge sidecars. The backend already creates it (_ensure_authbridge_configmaps() in agents.py), but users cannot customize the values through the UI.

Key configurable parameters:

Key Description Current behavior
KEYCLOAK_URL Keycloak server URL Set from settings.keycloak_url
KEYCLOAK_REALM Keycloak realm Set from settings.effective_keycloak_realm
DEFAULT_OUTBOUND_POLICY passthrough (default) or exchange Not exposed
ISSUER JWT issuer for inbound validation Derived from KEYCLOAK_URL + realm
EXPECTED_AUDIENCE Expected audience in inbound JWTs Not exposed
PLATFORM_CLIENT_IDS Comma-separated platform client IDs Not exposed

UI change needed:

  • Add an expandable "AuthBridge Configuration" section (advanced) with fields for:
    • Default Outbound Policy: dropdown (passthrough / exchange)
    • Expected Audience: text input (optional)
    • Platform Client IDs: text input (optional, comma-separated)
    • Issuer Override: text input (optional, for split-horizon DNS scenarios)
  • Backend: pass these values into _ensure_authbridge_configmaps() or update the ConfigMap if it already exists

Gap 6: Port exclusion annotations

Priority: Low

The webhook supports per-workload port exclusion via annotations on the pod template:

  • kagenti.io/outbound-ports-exclude: comma-separated ports to exclude from outbound interception
  • kagenti.io/inbound-ports-exclude: comma-separated ports to exclude from inbound interception

Port 8080 is always excluded for outbound (Keycloak).

UI change needed:

  • Add optional text fields in the Advanced section: "Excluded Outbound Ports", "Excluded Inbound Ports"
  • Backend: set the annotations on the pod template metadata

Implementation Guidance

Files to modify

Frontend:

  • kagenti/ui-v2/src/pages/ImportAgentPage.tsx — state variables, form controls, submission
  • kagenti/ui-v2/src/pages/ImportToolPage.tsx — same changes
  • kagenti/ui-v2/src/services/api.ts — API types (CreateAgentRequest, CreateToolRequest, FinalizeShipwrightBuildRequest)

Backend:

  • kagenti/backend/app/routers/agents.py — CreateAgentRequest model, _build_agent_labels(), _ensure_authbridge_configmaps(), finalize endpoint
  • kagenti/backend/app/routers/tools.py — same pattern

TUI (keep in sync):

  • kagenti/tui/internal/api/types.go — AgentRequest struct
  • kagenti/tui/internal/ui/views/deployagent.go — form fields
  • kagenti/tui/internal/cli/deploy.go — CLI flags

Label mapping reference (webhook to UI)

Webhook label/annotation UI field Default
kagenti.io/inject authBridgeEnabled toggle enabled (agents) / disabled (tools)
kagenti.io/spire spireEnabled toggle not set
kagenti.io/envoy-proxy-inject envoyProxyInject toggle not set (= inject)
kagenti.io/spiffe-helper-inject spiffeHelperInject toggle not set (= inject)
kagenti.io/client-registration-inject clientRegistrationInject toggle not set (= skip, operator-managed)
kagenti.io/outbound-ports-exclude outboundPortsExclude text not set
kagenti.io/inbound-ports-exclude inboundPortsExclude text not set

Suggested phasing

  1. Phase 1 (bug fix): Fix the AuthBridge checkbox description (Gap 1) — trivial, should go in ASAP
  2. Phase 2 (core): Per-sidecar controls (Gap 2) + outbound routing (Gap 4) — these are the most impactful for usability
  3. Phase 3 (advanced): authbridge-config editing (Gap 5) + combined mode indicator (Gap 3) + port exclusions (Gap 6)

Cross-repo references

PR Repo What changed
#254 kagenti-extensions Combined AuthBridge sidecar mode (combinedSidecar feature gate)
#262 kagenti-extensions Operator-managed Keycloak client credentials; client-registration sidecar now opt-in
kagenti-operator#247 kagenti-operator Operator-side client registration controller

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions