Commit Graph

3 Commits

Author SHA1 Message Date
Juan Garces
6efcd0a1e7 test(auth): exercise the real OIDC client instead of a stand-in
The previous test built its own AsyncOAuth2Client and passed an explicit
code_verifier, so it asserted Authlib's behaviour rather than RomM's and
passed with or without the fix.

Drive oauth.openid.authorize_redirect (what /api/login/openid calls) and
assert the challenge on the redirect matches the verifier saved to the
session, which is the pair the callback needs to redeem the code.
2026-08-22 15:14:57 -05:00
Juan Garces
316734b3fb style(auth): trim the PKCE comment and docstrings to repo convention
CLAUDE.md caps a comment at one or two lines and a docstring at one
sentence. The rationale that was inline (the failure mode, the
backwards-compatibility argument, the OAuth 2.1 reference) belongs in the
PR body, so what stays is the one fact the code cannot convey: Authlib
derives no code_verifier unless code_challenge_method is set.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 13:08:07 -05:00
Juan Garces
eadd8fe5c3 fix(auth): send PKCE on the OIDC authorization request
Authlib only derives a code_verifier when `code_challenge_method` is set
on the client, so the OIDC client registered in `decorators/auth.py` sent
no `code_challenge` at all. Against a provider that mandates PKCE the user
authenticates successfully and is then redirected back without a `code`,
which surfaces as a generic login failure with nothing useful in the logs.

Set `code_challenge_method: "S256"` in `client_kwargs`. Providers that do
not support PKCE ignore the extra parameters (OIDC Core 3.1.2.1), so this
is backwards-compatible, and OAuth 2.1 requires PKCE of every client.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 12:47:26 -05:00