Skip to content

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

Closed

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

Activity

  1. Alan-Cha commented on Sep 21, 2026

    @Alan-Cha
    MemberAuthor

    This was already resolved by #517 (commit 8c2bf23), merged the day after this issue was filed. pod_mutator.go now logs a warning when multiple audiences are specified and uses the first one, with a comment linking back to this issue:

    if len(outboundRoute.Audiences) > 1 {
        mutatorLog.Info("multiple audiences specified but only first will be used",
            "namespace", namespace, "crName", crName,
            "route", outboundRoute.Destination.Host,
            "audiences", outboundRoute.Audiences,
            "using", outboundRoute.Audiences[0])
    }

    Verified present on main. The "reject entirely" alternative was not adopted; the warning-log approach was. The optional idea of also emitting a Kubernetes Event on the AgentRuntime CR was not implemented — happy to open a follow-up if that's still wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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