Implement LOLA-compliant OAuth2 validator and enhance Application registration #129
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.
This PR focus on enforcing LOLA specification compliance through a custom validator and improving the application registration experience.
These changes ensure our testbed properly supports secure service-to-service authorization flows for account transfers.
Validator Implementation
The core of this PR is the new
ActivityPubOAuth2Validator.The validator performs two critical functions:
First, it validates that all OAuth requests include the '
activitypub_account_portability' scope, rejecting any authorization attempts that don't explicitly request this scope. This ensures our OAuth endpoints can only be used for their intended purpose - ActivityPub account portability - rather than general authentication or other API access.Second, it enforces redirect URI validation, ensuring authorization codes are only sent to pre-registered destinations.
The validator has been registered in the Django settings and is now active for all OAuth flows. django-oauth-toolkit will automatically use this validator for all OAuth requests.
It's actively enforcing LOLA compliance for all OAuth flows in the application right now. When a destination service initiates an OAuth request without the proper scope or with an invalid redirect URI, this validator will reject it, protecting the system from misuse.
Form and Utility Enhancements
This PR also enhances the application registration form to display the service name field with appropriate labels and help text. The service name is important in the OAuth flow as it appears on the authorization screen that users see when approving account transfers
Close #130