Commit graph

34520 commits

Author SHA1 Message Date
Ishaan Jaffer
22e103f31a add redirect_uri assertion, userinfo body in non-200 log, sentinel comment 2026-03-06 17:41:42 -08:00
Ishaan Jaffer
48f0e32ef7 add best-effort cleanup in strict-mode for corrupt/empty cache entries 2026-03-06 17:29:35 -08:00
Ishaan Jaffer
f5412135ce fix misleading comments: code_verifier init and bearer-credential merge docs 2026-03-06 16:56:50 -08:00
Ishaan Jaffer
7ce09e124e add sentinel guard so pkce-no-redis warning only fires once across hot-reloads 2026-03-06 16:40:04 -08:00
Ishaan Jaffer
579078f468 fix test: configure async_delete_cache as AsyncMock and assert cleanup called 2026-03-06 16:26:58 -08:00
Ishaan Jaffer
faa8e29cd9 clean up stale pkce verifier cache entries in non-strict mode 2026-03-06 16:12:28 -08:00
Ishaan Jaffer
17b5b90526 remove dead-code response=None guard in _pkce_token_exchange 2026-03-06 16:02:27 -08:00
Ishaan Jaffer
a439c437df use caplog to verify warning logs in non-strict cache miss tests
The two non-strict mode tests now use pytest's caplog fixture to assert
that a warning is actually emitted, not just that the code continues
without raising. This catches regressions where the warning silently
disappears.
2026-03-06 15:27:56 -08:00
Ishaan Jaffer
d987fd1227 address greptile review feedback (greploop iteration 42)
- assert null id_token is absent from merged result in basic auth test
- add test for HTTP 200 empty/null userinfo body with no id_token fallback
2026-03-06 15:14:53 -08:00
Ishaan Jaffer
2c268bc22d address greptile review feedback (greploop iteration 41)
- add Bearer token header assertion to test_pkce_token_exchange_credentials_in_body
- add cache query assertions to both non-strict mode tests to confirm
  the cache was accessed before the warning path triggers
2026-03-06 15:01:20 -08:00
Ishaan Jaffer
427d013d8c add credential absence assertions to test_pkce_token_exchange_basic_auth
Verify that client_id and client_secret are NOT double-sent in the POST
body when Basic Auth is used (include_client_id=False with client_secret).
Catches regressions where credentials leak into both Auth header and body.
2026-03-06 14:48:23 -08:00
Ishaan Jaffer
0c60c0f892 address greptile review feedback (greploop iteration 40)
- fix duplicate error logging: demote first format-error log to DEBUG
  so the detailed ERROR in strict-mode branch is not duplicated
- add HTTP status code assertions to all PKCE ProxyException tests
  for better regression protection against accidental code changes
2026-03-06 14:30:54 -08:00
Ishaan Jaffer
9b87bdf176 use HTTP 401 for PKCE missing config errors
GENERIC_CLIENT_ID and GENERIC_TOKEN_ENDPOINT missing when PKCE is
enabled are auth-flow failures, not server errors. Use 401 instead
of 500 to avoid triggering false-positive server error alerts in
monitoring systems.
2026-03-06 14:17:51 -08:00
Ishaan Jaffer
1bc6e2a2a5 fix _OAUTH_TOKEN_FIELDS merge loop to preserve userinfo values on absent fields
When the token endpoint omits a bearer-credential field entirely (field
absent from token_response), the previous code deleted it from merged even
if userinfo provided a valid value. Now:
- non-null in token_response → restore authoritative token endpoint value
- explicit null in token_response → remove key from merged (clean absence)
- field absent from token_response → leave userinfo value unchanged
2026-03-06 13:01:47 -08:00
Ishaan Jaffer
0c647d4be9 address greptile review feedback (greploop iteration 39)
- fix credential leakage: directly assign received_response from
  combined_response instead of relying on nonlocal mutation; Pyright
  was flagging the old guard as unreachable, meaning credential stripping
  might not execute — now it always runs unconditionally
- add test for legacy plain-string cache format backward compat branch
- add test for HTTP 200 with no error field and no access_token (else branch)
- add test for HTTP 200 with JSON null body (new AttributeError guard)
2026-03-06 12:49:12 -08:00
Ishaan Jaffer
aec865bf54 fix null JSON response body in _pkce_token_exchange
- Guard against HTTP 200 with body null: response.json() returns None
  for JSON null, and calling .get() on None raises AttributeError.
  Now raises a clean ProxyException with a clear error message.
- Fix misleading userinfo warning: was always saying "empty dict" but
  also fires for JSON null responses; updated to say "empty or null".
- Add HTTP status code assertion to cache miss test.
2026-03-06 12:34:35 -08:00
Ishaan Jaffer
6143c42f66 address greptile review feedback (greploop iteration 38)
- fix strict-mode cache miss error message to differentiate
  cross-instance routing failures (Redis configured) from single-instance
  issues (TTL expiry, pod restart) when only in-memory cache is available
- add comment above _get_pkce_userinfo call explaining that bearer
  credentials are always sourced from token_response in the merge step
2026-03-06 12:16:41 -08:00
Ishaan Jaffer
53297dc885 defer PKCE verifier deletion until after all downstream processing
Move _delete_pkce_verifier to after response_convertor and
process_sso_jwt_access_token complete. If JWT processing raises,
the verifier stays in cache so the user can retry without restarting
the full OAuth flow.
2026-03-06 11:56:41 -08:00
Ishaan Jaffer
e8906aa670 address greptile review feedback (greploop iteration 37)
- read GENERIC_CLIENT_USE_PKCE env var once in prepare_token_exchange_parameters
- include actual decode error in jwt.decode failure exception message
- add GENERIC_CLIENT_USE_PKCE=true to no-state regression test
2026-03-06 11:36:26 -08:00
Ishaan Jaffer
485da8a208 address greptile review feedback (greploop iteration 35) 2026-03-06 11:12:39 -08:00
Ishaan Jaffer
ef0b463d0f address greptile review feedback (greploop iteration 34) 2026-03-06 11:11:39 -08:00
Ishaan Jaffer
f85229a393 address greptile review feedback (greploop iteration 33) 2026-03-06 11:00:01 -08:00
Ishaan Jaffer
06f12e0ddf address greptile review feedback (greploop iteration 32) 2026-03-06 10:38:21 -08:00
Ishaan Jaffer
04d3d55287 address greptile review feedback (greploop iteration 31) 2026-03-06 10:14:56 -08:00
Ishaan Jaffer
6f7cd4baa9 address greptile review feedback (greploop iteration 30) 2026-03-06 10:02:20 -08:00
Ishaan Jaffer
3e704e72f9 address greptile review feedback (greploop iteration 29) 2026-03-06 09:50:21 -08:00
Ishaan Jaffer
e55e7546d0 address greptile review feedback (greploop iteration 28) 2026-03-06 09:29:15 -08:00
Ishaan Jaffer
7e8b9d50e8 address greptile review feedback (greploop iteration 27) 2026-03-05 20:24:17 -08:00
Ishaan Jaffer
13f8ecf27b address greptile review feedback (greploop iteration 26) 2026-03-05 20:12:13 -08:00
Ishaan Jaffer
759abb781f address greptile review feedback (greploop iteration 25) 2026-03-05 19:58:37 -08:00
Ishaan Jaffer
0fe3cec376 address greptile review feedback (greploop iteration 24) 2026-03-05 19:48:54 -08:00
Ishaan Jaffer
b7e8eb4235 address greptile review feedback (greploop iteration 23) 2026-03-05 19:23:17 -08:00
Ishaan Jaffer
e718404c22 address greptile review feedback (greploop iteration 22) 2026-03-05 19:07:12 -08:00
Ishaan Jaffer
b7df1f3d1b address greptile review feedback (greploop iteration 21) 2026-03-05 18:52:09 -08:00
Ishaan Jaffer
cd4d672f7e address greptile review feedback (greploop iteration 20) 2026-03-05 18:31:42 -08:00
Ishaan Jaffer
1252ea871a address greptile review feedback (greploop iteration 19) 2026-03-05 18:21:47 -08:00
Ishaan Jaffer
d66ed5e412 address greptile review feedback (greploop iteration 18) 2026-03-05 17:52:21 -08:00
Ishaan Jaffer
a9eb399d9e address greptile review feedback (greploop iteration 17) 2026-03-05 17:38:32 -08:00
Ishaan Jaffer
63de6d0ee0 address greptile review feedback (greploop iteration 16) 2026-03-05 17:20:40 -08:00
Ishaan Jaffer
8b491790b6 address greptile review feedback (greploop iteration 15) 2026-03-05 17:06:22 -08:00
Ishaan Jaffer
e72018db28 address greptile review feedback (greploop iteration 14) 2026-03-05 16:54:13 -08:00
Ishaan Jaffer
cbb6b6700f address greptile review feedback (greploop iteration 13) 2026-03-05 16:15:11 -08:00
Ishaan Jaffer
dfac66ed51 fix misleading comment on user_api_key_cache TTL line 2026-03-05 16:01:48 -08:00
Ishaan Jaffer
bf27a497c3 address greptile review feedback (greploop iteration 12) 2026-03-05 15:48:51 -08:00
Ishaan Jaffer
f953e171e1 address greptile review feedback (greploop iteration 11) 2026-03-05 15:29:14 -08:00
Ishaan Jaffer
1f503fdcbd address greptile review feedback (greploop iteration 10) 2026-03-05 15:15:47 -08:00
Ishaan Jaffer
de15b54c00 address greptile review feedback (greploop iteration 9) 2026-03-05 15:02:23 -08:00
Ishaan Jaffer
d8906d33f7 address greptile review feedback (greploop iteration 8) 2026-03-05 14:50:32 -08:00
Ishaan Jaffer
27f766424d address greptile review feedback (greploop iteration 7) 2026-03-05 14:39:23 -08:00
Ishaan Jaffer
6001a0b30c address greptile review feedback (greploop iteration 6) 2026-03-05 14:29:08 -08:00