From 7301e3ab7c5b31c3433b4848db1c7d22e1211d2a Mon Sep 17 00:00:00 2001 From: Craig de Stigter Date: Wed, 3 Dec 2025 17:37:07 +1300 Subject: [PATCH 1/2] feat: add RFC 8707 Resource Indicators support Fixes #1102 Implement RFC 8707 to bind access tokens to specific resource servers: - Add resource field to Grant and AccessToken models (migrations included) - Accept & validate resource parameter in authorization/token requests - token view: reject unauthorized resources with `invalid_target` error This change is backward compatible - clients not providing a `resource` in the request will receive a token providing unrestricted access, as before. --- CHANGELOG.md | 4 + docs/getting_started.rst | 11 + docs/resource_server.rst | 76 ++- oauth2_provider/forms.py | 1 + .../migrations/0014_grant_resource.py | 17 + .../migrations/0015_accesstoken_resource.py | 17 + oauth2_provider/models.py | 47 ++ oauth2_provider/oauth2_validators.py | 96 +++- oauth2_provider/views/base.py | 22 + oauth2_provider/views/introspect.py | 6 + tests/app/idp/pyproject.toml | 2 +- tests/test_authorization_code.py | 91 ++++ tests/test_introspection_view.py | 42 ++ tests/test_models.py | 50 ++ tests/test_rfc8707_integration.py | 501 ++++++++++++++++++ 15 files changed, 978 insertions(+), 5 deletions(-) create mode 100644 oauth2_provider/migrations/0014_grant_resource.py create mode 100644 oauth2_provider/migrations/0015_accesstoken_resource.py create mode 100644 tests/test_rfc8707_integration.py diff --git a/CHANGELOG.md b/CHANGELOG.md index a29772c13..fb9abf1d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Support for Django 5.2 * Support for Python 3.14 (Django >= 5.2.8) * #1539 Add device authorization grant support +* RFC 8707 "Resource Indicators" support + - clients can optionally specify `resource` parameter during authorization or access token requests + - Resource binding stored in Grant and AccessToken models + - Token introspection endpoint returns `aud` claim for tokens with resource indicators