Centralize LOLA portability scope enforcement - #280
Draft
aaronjae22 wants to merge 6 commits into
Draft
Conversation
…string to validate_scopes
…e and drop the duplicate constants
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #279. (PR 1/3)
Something that I found during the first round of testing. This is a small but useful refactor. We had the LOLA portability scope in 7 definitions and 4 manual checks. Now we collapse everything down to one owned module.
activitypub_account_portabilitywas written out in 7 places, and the question "does this scope grant portability?" had 4 independent implementations receiving 3 different input shapes - an oauthliblistatvalidate_scopes, and space-delimited strings everywhere else.The neew
testbed/core/oauth/scopes.pyownsLOLA_PORTABILITY_SCOPEandscope_grants_portability(). The helper splits on a single space per RFC 6749 §3.3 before comparing. This matches what oauthlib and DOT actually emit.All four decisions now call it:
validate_scopes,_save_bearer_token,_has_portability_scope,_prepare_actor_binding.I added a docstring on
validate_scopesthat indicates that this server is deliberately stricter than §5 requires for now since it rejects every grant lacking the portability scope, which §5 does not mandate. A comment claiming non-portability federation tokens "keep working unchanged" was removed; they can't be issued here since we don't have any other scope available yet.OAUTH2_PROVIDER['SCOPES']still repeats the literal, because settings modules must not import app code.LOLA spec
§5: "The advertised OAuth endpoint MUST support the
activitypub_account_portabilityscope. That scope MUST be limited to one account."validate_scopesis where the first MUST is enforced, and it's the gate that decides whether a token gets Actor-bound for the second. A false accept there would produce a token that reads as LOLA-scoped everywhere downstream.