← Back to Pull requests

fix(rest-proxy): let registry credentials coexist with forwarded auth header #1372

Closed
unknown closed this pull request without merging on Sep 11, 2026 07:03 UTC
View on GitHub
unknown unknown commented on Sep 09, 2026 18:48 UTC
Author

1. Let registry_user/registry_password coexist with a forwarded Authorization
header.
Previously, whenever OIDC token forwarding was on, these had to be unset —
otherwise the forwarded bearer/basic header collided with the proxy's session-level
basic auth and aiohttp raised Cannot combine AUTHORIZATION header with AUTH argument,
surfacing as a 500.

2. Surface SR auth failures as real 401/403 instead of the generic 40801
("Error when registering schema"), which masked whether a failure was auth, schema
incompatibility, or the registry being down.

## What changed

Per-request auth (fix 1)
- core/client.py: no longer bakes session_auth into the aiohttp ClientSession. A new
_resolve_auth picks credentials per request — a forwarded Authorization header wins;
otherwise fall back to session_auth (registry_user/registry_password).

Auth error propagation (fix 2)
- kafka_rest_apis/error_codes.py: add HTTP_UNAUTHORIZED (401), HTTP_FORBIDDEN (403).
- core/serialization.py: SchemaRetrievalError carries the registry's HTTP status_code.
- kafka_rest_apis/__init__.py: map SR 401/403 to a matching proxy response; the
consume-by-id path no longer masks an auth failure as an invalid schema.

## Behavior matrix (SR OIDC + authfile)

| Client → proxy | Sent to SR | Result |
|---|---|---|
| Bearer <token> | forwarded token | OIDC-validated |
| Basic <creds> | forwarded basic | authfile-validated |
| nothing | registry_user/registry_password | service-credential fallback |
| invalid/expired token or creds | (as above) | 401/403 |

Tests

- Unit: tests/unit/core/test_client.py (_resolve_auth + on-the-wire selection);
tests/unit/kafka_rest_apis/test_registry_auth_error.py (status propagation + 401/403 mapping).
- E2E (tests/e2e/kafka_rest_apis/test_oidc_forwarding.py): coexistence (bearer + configured
creds), forwarded-basic to an OIDC+authfile SR, and updated auth-rejection cases now
asserting 401. Two new compose proxy services (-oidc-with-creds, -oidc-basic).

## Docs

- website/docs/authentication.md and README.rst: coexistence and the 401/403 vs 40801/42205
error behavior.

Diff: 289 lines (+216 / -73) across 3 files Reviewer: muralibasani Review duration: 2175m
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.63) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.63 · 289 lines diff across 3 files
0.63
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.339
Shallow Review Depth shallow_review_depth
0.289
Sensitive Paths sensitive_paths
0.063
Real PR Conversation Timeline
1 comments
"Review active on #1372"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 63% (MEDIUM) · Higher = larger blast radius
63%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 24.9% · Safe to merge
24.9%