-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(oauth): Implement PKCE (S256) and enforce redirect_uri binding #99452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
RFCs: - RFC 7636 (PKCE): §4.1/§4.2/§4.3/§4.4/§4.6 - RFC 6749 (OAuth 2.0): §4.1.3 (redirect_uri binding) - OAuth 2.1 draft (draft-ietf-oauth-v2-1-13) Changes: - Model/migration: add ApiGrant.code_challenge + code_challenge_method (nullable) - Authorization: accept + persist code_challenge(+_method); default S256; deny plain by default - Token: require code_verifier when grant has challenge; length/charset per RFC 7636; S256 verification; optional plain behind flag - Token: enforce redirect_uri equality when stored on grant (no fallback) - Tests: S256 happy path; missing/mismatch/length/charset; optional plain; redirect binding Notes: - Local constants gate plain method; discovery metadata excluded (separate task) - No implicit flow changes; non-cacheable responses preserved Refs: #99002
…etrics - v0: log warnings when redirect_uri fallback or missing PKCE verifier are used - v1: unchanged strict behavior RFCs: RFC 7636; RFC 6749 §4.1.3 Refs: #99002
|
This PR has a migration; here is the generated SQL for for --
-- Add field code_challenge to apigrant
--
ALTER TABLE "sentry_apigrant" ADD COLUMN "code_challenge" varchar(128) NULL;
--
-- Add field code_challenge_method to apigrant
--
ALTER TABLE "sentry_apigrant" ADD COLUMN "code_challenge_method" varchar(10) NULL; |
…rsion - v1: reject code_challenge_method=plain at authorize and token - v0: allow plain for compatibility - Update tests to switch app version for plain success path RFCs: RFC 7636 (PKCE); RFC 6749 §4.1.3 Refs: #99002
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #99452 +/- ##
==========================================
- Coverage 81.32% 81.21% -0.11%
==========================================
Files 8590 8584 -6
Lines 382261 380205 -2056
Branches 24106 24106
==========================================
- Hits 310864 308778 -2086
- Misses 71051 71081 +30
Partials 346 346 |
|
This one will need a bit more thorough of a review. 2.1 changes the hard requirements so once again we're not enforcing these til version=1. Will give it another pass myself |
|
I'm going to redo this patch from scratch given the model changes, but working on this now. |
RFCs:
Changes:
Notes:
Refs: #99002