PR #363 (sso_user_id_updates by CapitolCoder) — 527 additions, 8 deletions, 3 files
PR #362 (feature/COM-18-ad-phase-1 by jordotech) — 8 additions, 1 deletion, 1 file
Both PRs add Authorization: Bearer header support to get_current_user() so SSO users can authenticate with agentic-backend.
| Aspect | PR #363 | PR #362 (ours) |
|---|---|---|
| Lines changed (impl) | 19 additions, 8 deletions | 8 additions, 1 deletion |
| Lines changed (tests) | 508 additions | 0 (manual test plan) |
| Files | 3 (auth.py + 2 new test files) | 1 (auth.py only) |
| Bearer parsing | startswith("Bearer ") + removeprefix("Bearer ") |
split(None, 1) + casefold() (RFC 7235) |
check_token() change |
Sends both X-User-Token and Authorization: Bearer headers |
No change — sends X-User-Token only |
Both PRs add the same 3-line pattern to get_current_user():
# PR #363
token = x_user_token
if not token and authorization and authorization.startswith("Bearer "):
token = authorization.removeprefix("Bearer ")
# PR #362
token = x_user_token
if not token and authorization:
parts = authorization.split(None, 1)
if len(parts) == 2 and parts[0].casefold() == "bearer":
token = parts[1].strip()-
Case-sensitive Bearer parsing —
startswith("Bearer ")fails onbearer,BEARER, orbearerwhich are all valid per RFC 7235 Section 2.1. Our PR usescasefold()for case-insensitive matching, which was specifically flagged and fixed based on GitHub Copilot review feedback. -
Unnecessary
check_token()dual-header change — PR #363 modifiescheck_token()to forward bothX-User-TokenandAuthorization: Bearerto platform-api. This is unnecessary because:- Platform-api's
/validateendpoint readsX-User-Tokenheader - The token is the same regardless of which header it came from
- Sending both just doubles the header traffic with no benefit
- It also means platform-api's
/validatenow needs to handleAuthorizationheader parsing, adding scope to a different PR
- Platform-api's
-
508 lines of tests for a 3-line change — Two new test files with extensive mocking of aiohttp context managers. The tests are thorough but the ratio is extreme for what is essentially a header extraction change.
-
Import reordering — Reformats all imports in
auth.py(isort-style). While clean, it creates unnecessary diff noise and potential merge conflicts.
- Good test coverage for edge cases (empty Bearer, missing prefix, priority ordering)
- Documents the dual-header contract clearly in docstrings
- Tests verify
check_token()sends headers correctly
PR #362 is the better choice. It's a minimal, focused change (8 lines, 1 file) that solves the exact problem — SSO users sending Authorization: Bearer couldn't authenticate. The RFC 7235-compliant parsing handles edge cases that PR #363 misses. The check_token() dual-header change in PR #363 is unnecessary and adds coupling between agentic-backend and platform-api's header handling.
The test files from PR #363 could be adapted and added as a follow-up if test coverage is desired, but the implementation from PR #362 should be used.