fix: Default outbound policy to passthrough, preventing token exchange failures#185
Merged
mrsabath merged 2 commits intoMar 10, 2026
Conversation
…cess Add Step 10 to both demo-manual.md and demo-ui.md demonstrating scope-based access control: Alice (public only) vs Bob (privileged) through AuthBridge token exchange. - Add REQUIRED_SCOPE env var to github-tool-deployment.yaml - Add Step 10 (10a-10f) with Alice/Bob access control walkthrough - Update demo.md overview with access control description - Clarify scope forwarding dependency (rossoctl#139) in flow description - Explain why Bob explicitly requests github-full-access (realm OPTIONAL scope) - Update all Keycloak URLs from demo realm to kagenti realm Depends on: kagenti-extensions#139 (scope forwarding) Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Mariusz Sabath <mrsabath@gmail.com>
…e failures for LLM and telemetry traffic The go-processor previously attempted token exchange for ALL plaintext HTTP outbound traffic when global config (TARGET_AUDIENCE, TARGET_SCOPES) was set. This broke agents using in-cluster HTTP services (Ollama, otel-collector) because non-Keycloak tokens (like API keys) were rejected by Keycloak with Invalid token or invalid_scope errors. This change inverts the default: outbound requests that do not match any route in routes.yaml now pass through unchanged. Token exchange only happens for hosts with explicit route entries in authproxy-routes ConfigMap. A DEFAULT_OUTBOUND_POLICY env var (passthrough default, exchange for legacy) provides backward compatibility. Changes: - go-processor: Add DEFAULT_OUTBOUND_POLICY env var and passthrough-by-default logic - go-processor: Add passthroughResponse() helper, refactor handleOutbound() - go-processor: Add comprehensive tests for outbound policy behavior - webhook: Mount optional authproxy-routes ConfigMap volume (Optional: true) - webhook: Add ROUTES_CONFIG_PATH and DEFAULT_OUTBOUND_POLICY env vars to envoy-proxy - github-issue demo: Add authproxy-routes ConfigMap with route for github-tool - webhook demo: Add DEFAULT_OUTBOUND_POLICY docs and commented routes example - docs: Update CLAUDE.md and AuthBridge/CLAUDE.md with new policy and ConfigMap Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Mariusz Sabath <mrsabath@gmail.com>
mrsabath
force-pushed
the
fix/passthrough-by-default-outbound-policy
branch
from
March 10, 2026 17:51
4d46b31 to
4a224bf
Compare
Member
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
This was referenced Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the root cause of kagenti/kagenti#882 from the kagenti-extensions side.
The go-processor previously attempted token exchange for all plaintext HTTP outbound traffic when global config (
TARGET_AUDIENCE,TARGET_SCOPES) was set. This broke agents using in-cluster HTTP services (Ollama for LLM, otel-collector for telemetry) because non-Keycloak tokens (like API keys) were rejected with"Invalid token"or"invalid_scope"errors. External HTTPS LLM APIs (OpenAI, Anthropic) happened to work only because Envoy TLS passthrough bypasses the ext_proc entirely.This PR inverts the default: outbound requests that don't match any route pass through unchanged. Token exchange only happens for hosts with explicit entries in an
authproxy-routesConfigMap.Changes
DEFAULT_OUTBOUND_POLICYenv var ("passthrough"default,"exchange"for legacy backward compat) and insert passthrough check inhandleOutbound()for unmatched hostspassthroughResponse()helper to reduce duplicationTestDefaultOutboundPolicy,TestOutboundPolicyWithRoutes,TestOutboundPolicyRouteMatchExchangeFails) using httptest mock Keycloakauthproxy-routesConfigMap volume (Optional: trueso pods don't fail if it doesn't exist)ROUTES_CONFIG_PATHandDEFAULT_OUTBOUND_POLICYenv vars to envoy-proxy containerauthproxy-routesConfigMap with explicit route entry for github-tool (so token exchange still works for that demo)DEFAULT_OUTBOUND_POLICYdocumentation and commented-outauthproxy-routesexampleCLAUDE.mdandAuthBridge/CLAUDE.mdwith new policy, ConfigMap, and behaviorHow it works
Companion change needed in kagenti/kagenti
The Helm chart in
charts/kagenti/templates/agent-namespaces.yamlcurrently createsauthbridge-configwith hardcodedTARGET_AUDIENCE: "auth-target"andTARGET_SCOPES: "openid auth-target-aud". With this PR, those values become fallbacks only used when a route matches but doesn't specify its own audience/scopes (or whenDEFAULT_OUTBOUND_POLICY=exchange). The Helm chart should be updated to either:TARGET_AUDIENCE/TARGET_SCOPESfrom the defaultauthbridge-config(since passthrough is now the default and routes provide per-target config), orThe weather agent demo and all other agents will work out-of-the-box after this change without needing the
auth-target-audscope to exist in Keycloak.Test plan
go test ./go-processor/...)go test ./go-processor/internal/resolver/...)make testin kagenti-webhook/)TestDefaultOutboundPolicyvalidates passthrough for Ollama, otel-collector, and arbitrary hostsTestDefaultOutboundPolicyLegacyExchangevalidates backward compat withexchangepolicyTestOutboundPolicyWithRoutesvalidates github-issue pattern (route-based exchange + LLM passthrough)TestOutboundPolicyRouteMatchExchangeFailsvalidates 503 on Keycloak errors for routed hosts