feat(oauth): Add strict redirect URI validation mode#99003
Conversation
|
This PR has a migration; here is the generated SQL for for --
-- Add field allow_redirect_prefix_match to apiapplication
--
ALTER TABLE "sentry_apiapplication" ADD COLUMN "allow_redirect_prefix_match" boolean DEFAULT false NOT NULL;
--
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL |
|
Open to changing the migration here, and while it has the chance to cause a minor blip for some folks, its hugely unlikely and saves us from having to make sure any paths that update the apps are also updated to write the actual-default |
8c03738 to
2fe97d0
Compare
|
oh one other open q: can you use a diff db_default vs default and have it do what you might want here? e.g. db_default=True, default=False, and have new entries created via the app be inverted? I dont recall how all this works aside this table should be tiny which is why i didnt bother with nullable ddl |
2fe97d0 to
45b4389
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #99003 +/- ##
==========================================
- Coverage 81.29% 81.28% -0.01%
==========================================
Files 8545 8545
Lines 377549 377688 +139
Branches 23999 23999
==========================================
+ Hits 306923 307003 +80
- Misses 70275 70334 +59
Partials 351 351 |
45b4389 to
e51c216
Compare
|
I'm actually considering just adding a versioning flag to the api application, as theres going to be a ton of minor incompatible changes and we wont want flags for each one. This one is kind of ok, and may be one of the few that has real consequences, but for example theres things like 'implicit' grants being deprecated etc. |
|
I'm going to swap to a version field - otherwise we need to add a bitflag here and id pref to avoid that unless really needed. We'll then give folks a time window (if needed) and deprecate the legacy applications (force upgrade them). Will keep the logging pattern for any legacy/future-unsupported behavior. |
ee5b06b to
307cf94
Compare
|
This PR has a migration; here is the generated SQL for for --
-- Add field version to apiapplication
--
ALTER TABLE "sentry_apiapplication" ADD COLUMN "version" integer DEFAULT 0 NOT NULL CHECK ("version" >= 0);
CREATE INDEX CONCURRENTLY "sentry_apiapplication_version_aeec73fd" ON "sentry_apiapplication" ("version"); |
|
@oioki oof ancient PR - if theres any others your aware of, or low hanging fruit that just couldnt get pushed through lmk happy to help |
Add `allow_redirect_prefix_match` field to ApiApplication model to control redirect URI validation behavior. When False (default for new apps), redirect URIs must match exactly. When True (migrated existing apps), legacy prefix matching is allowed. This improves OAuth security by preventing redirect URI manipulation attacks while maintaining backward compatibility for existing applications. Fixes #99001
ba046aa to
cf60c19
Compare
|
This PR has a migration; here is the generated SQL for for --
-- Add field version to apiapplication
--
ALTER TABLE "sentry_apiapplication" ADD COLUMN "version" integer DEFAULT 0 NOT NULL CHECK ("version" >= 0);
CREATE INDEX CONCURRENTLY "sentry_apiapplication_version_aeec73fd" ON "sentry_apiapplication" ("version"); |
| # defaults accordingly. | ||
| version = BoundedPositiveIntegerField( | ||
| default=0, | ||
| db_index=True, |
There was a problem hiding this comment.
Will we be querying on version directly, or on some compound key?
| # default and db_default to 1 and add a migration to update the field | ||
| # defaults accordingly. | ||
| version = BoundedPositiveIntegerField( | ||
| default=0, |
There was a problem hiding this comment.
You don't need to set both default and db_default. I'd just go with db_default here.
|
🙏 ty @mdtro |
|
just realzed after merging, but lets come back and delete the index later - i doubt we really need it so its a waste of memory can do it as part of the final migration where we update the versions |
Introduces version-gated exact redirect URI matching per OAuth 2.0 spec.
Refs:
Related: #99002