Skip to content

feat(webhook): validate/warn when AgentRuntime.spec.auth.outbound route has multiple audiences #518

Description

@Alan-Cha

Problem

The AgentRuntime CRD defines spec.auth.outbound[].audiences as an array (future-proofing), but AuthBridge's routing.Route struct only supports a single target_audience string.

Currently, the webhook silently takes the first audience and ignores any others:

// pod_mutator.go
if len(outboundRoute.Audiences) > 0 {
    route["target_audience"] = outboundRoute.Audiences[0]  // Only first is used
}

If a user specifies:

spec:
  auth:
    outbound:
      - destination:
          host: tool.svc.cluster.local
        audiences:
          - "spiffe://app1"
          - "spiffe://app2"  # ← SILENTLY IGNORED

The second audience is dropped without any feedback.

Proposed Solution

Add validation at webhook admission time:

if len(outboundRoute.Audiences) > 1 {
    mutatorLog.Info("Multiple audiences specified but only first will be used",
        "route", outboundRoute.Destination.Host,
        "audiences", outboundRoute.Audiences,
        "using", outboundRoute.Audiences[0])
    // Consider: add a warning event on the AgentRuntime CR
}

Alternative: Reject the AgentRuntime entirely if multiple audiences are specified (stricter, but clearer failure mode).

Context

  • AuthBridge source: cortex/authbridge/authlib/routing/router.go - Route struct has Audience string
  • CRD definition: operator/api/v1alpha1/agentruntime_types.go - has Audiences []string
  • The array format was chosen for future-proofing, but creates a mismatch with current AuthBridge capabilities

Related

/cc @alantech

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions