django-oauth-toolkit 3.2.0__tar.gz → 3.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/AUTHORS +5 -0
  2. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/MANIFEST.in +1 -0
  3. {django_oauth_toolkit-3.2.0/django_oauth_toolkit.egg-info → django_oauth_toolkit-3.3.0}/PKG-INFO +5 -6
  4. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/README.rst +2 -2
  5. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0/django_oauth_toolkit.egg-info}/PKG-INFO +5 -6
  6. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/django_oauth_toolkit.egg-info/SOURCES.txt +1 -0
  7. django_oauth_toolkit-3.3.0/oauth2_provider/__init__.py +1 -0
  8. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/admin.py +1 -0
  9. django_oauth_toolkit-3.3.0/oauth2_provider/migrations/0014_alter_help_text.py +20 -0
  10. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/models.py +6 -4
  11. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/oauth2_validators.py +6 -3
  12. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/device/accept_deny.html +6 -1
  13. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/utils.py +5 -2
  14. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/views/base.py +4 -5
  15. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/views/device.py +69 -14
  16. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/views/oidc.py +1 -1
  17. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/pyproject.toml +7 -5
  18. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_device.py +399 -15
  19. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_oauth2_validators.py +1 -1
  20. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_oidc_views.py +9 -0
  21. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_settings.py +41 -0
  22. django_oauth_toolkit-3.2.0/oauth2_provider/__init__.py +0 -1
  23. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/LICENSE +0 -0
  24. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/django_oauth_toolkit.egg-info/dependency_links.txt +0 -0
  25. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/django_oauth_toolkit.egg-info/requires.txt +0 -0
  26. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/django_oauth_toolkit.egg-info/top_level.txt +0 -0
  27. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/apps.py +0 -0
  28. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/backends.py +0 -0
  29. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/checks.py +0 -0
  30. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/compat.py +0 -0
  31. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/contrib/__init__.py +0 -0
  32. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/contrib/rest_framework/__init__.py +0 -0
  33. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/contrib/rest_framework/authentication.py +0 -0
  34. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/contrib/rest_framework/permissions.py +0 -0
  35. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/decorators.py +0 -0
  36. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/exceptions.py +0 -0
  37. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/forms.py +0 -0
  38. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/generators.py +0 -0
  39. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/http.py +0 -0
  40. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/management/__init__.py +0 -0
  41. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/management/commands/__init__.py +0 -0
  42. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/management/commands/cleartokens.py +0 -0
  43. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/management/commands/createapplication.py +0 -0
  44. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/middleware.py +0 -0
  45. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0001_initial.py +0 -0
  46. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0002_auto_20190406_1805.py +0 -0
  47. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0003_auto_20201211_1314.py +0 -0
  48. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0004_auto_20200902_2022.py +0 -0
  49. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0005_auto_20211222_2352.py +0 -0
  50. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0006_alter_application_client_secret.py +0 -0
  51. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0007_application_post_logout_redirect_uris.py +0 -0
  52. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0008_alter_accesstoken_token.py +0 -0
  53. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0009_add_hash_client_secret.py +0 -0
  54. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0010_application_allowed_origins.py +0 -0
  55. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0011_refreshtoken_token_family.py +0 -0
  56. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0012_add_token_checksum.py +0 -0
  57. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/0013_alter_application_authorization_grant_type_device.py +0 -0
  58. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/migrations/__init__.py +0 -0
  59. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/oauth2_backends.py +0 -0
  60. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/scopes.py +0 -0
  61. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/settings.py +0 -0
  62. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/signals.py +0 -0
  63. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/application_confirm_delete.html +0 -0
  64. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/application_detail.html +0 -0
  65. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/application_form.html +0 -0
  66. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/application_list.html +0 -0
  67. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/application_registration_form.html +0 -0
  68. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/authorize.html +0 -0
  69. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/authorized-token-delete.html +0 -0
  70. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/authorized-tokens.html +0 -0
  71. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/base.html +0 -0
  72. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/device/device_grant_status.html +0 -0
  73. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/device/user_code.html +0 -0
  74. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/templates/oauth2_provider/logout_confirm.html +0 -0
  75. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/urls.py +0 -0
  76. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/validators.py +0 -0
  77. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/views/__init__.py +0 -0
  78. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/views/application.py +0 -0
  79. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/views/generic.py +0 -0
  80. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/views/introspect.py +0 -0
  81. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/views/mixins.py +0 -0
  82. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/oauth2_provider/views/token.py +0 -0
  83. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/setup.cfg +0 -0
  84. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_application_views.py +0 -0
  85. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_auth_backends.py +0 -0
  86. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_authorization_code.py +0 -0
  87. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_client_credential.py +0 -0
  88. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_commands.py +0 -0
  89. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_decorators.py +0 -0
  90. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_django_checks.py +0 -0
  91. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_generator.py +0 -0
  92. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_hybrid.py +0 -0
  93. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_implicit.py +0 -0
  94. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_introspection_auth.py +0 -0
  95. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_introspection_view.py +0 -0
  96. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_mixins.py +0 -0
  97. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_models.py +0 -0
  98. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_oauth2_backends.py +0 -0
  99. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_oauth2_provider_middleware.py +0 -0
  100. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_password.py +0 -0
  101. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_rest_framework.py +0 -0
  102. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_scopes.py +0 -0
  103. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_scopes_backend.py +0 -0
  104. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_token_endpoint_cors.py +0 -0
  105. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_token_revocation.py +0 -0
  106. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_token_view.py +0 -0
  107. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_ui_locales.py +0 -0
  108. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_utils.py +0 -0
  109. {django_oauth_toolkit-3.2.0 → django_oauth_toolkit-3.3.0}/tests/test_validators.py +0 -0
@@ -26,6 +26,7 @@ Andrew Chen Wang
26
26
  Andrew Zickler
27
27
  Antoine Laurent
28
28
  Anvesh Agarwal
29
+ Aris Zhou
29
30
  Aristóbulo Meneses
30
31
  Aryan Iyappan
31
32
  Asaf Klibansky
@@ -47,6 +48,7 @@ David Smith
47
48
  David Uzumaki
48
49
  Dawid Wolski
49
50
  Diego Garcia
51
+ Diego Pasqualin
50
52
  Dominik George
51
53
  Dulmandakh Sukhbaatar
52
54
  Dylan Giesler
@@ -86,13 +88,16 @@ Jun Zhou
86
88
  Kaleb Porter
87
89
  Kristian Rune Larsen
88
90
  Lazaros Toumanidis
91
+ lrq315
89
92
  Ludwig Hähne
90
93
  Łukasz Skarżyński
91
94
  Madison Swain-Bowden
95
+ magicfelix
92
96
  Marcus Sonestedt
93
97
  Matej Spiller Muys
94
98
  Matias Seniquiel
95
99
  Michael Howitz
100
+ Michael "Irish" O'Neill
96
101
  Owen Gong
97
102
  Patrick Palacin
98
103
  Paul Dekkers
@@ -1,2 +1,3 @@
1
1
  include README.rst LICENSE
2
2
  recursive-include oauth2_provider/templates *.html
3
+ prune rfcs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: django-oauth-toolkit
3
- Version: 3.2.0
3
+ Version: 3.3.0
4
4
  Summary: OAuth2 Provider for Django
5
5
  Author: Federico Frenguelli, Massimiliano Pippi
6
6
  Author-email: synasius@gmail.com
@@ -41,19 +41,18 @@ Classifier: Framework :: Django :: 4.2
41
41
  Classifier: Framework :: Django :: 5.0
42
42
  Classifier: Framework :: Django :: 5.1
43
43
  Classifier: Framework :: Django :: 5.2
44
+ Classifier: Framework :: Django :: 6.0
44
45
  Classifier: Intended Audience :: Developers
45
46
  Classifier: License :: OSI Approved :: BSD License
46
47
  Classifier: Operating System :: OS Independent
47
48
  Classifier: Programming Language :: Python :: 3
48
- Classifier: Programming Language :: Python :: 3.8
49
- Classifier: Programming Language :: Python :: 3.9
50
49
  Classifier: Programming Language :: Python :: 3.10
51
50
  Classifier: Programming Language :: Python :: 3.11
52
51
  Classifier: Programming Language :: Python :: 3.12
53
52
  Classifier: Programming Language :: Python :: 3.13
54
53
  Classifier: Programming Language :: Python :: 3.14
55
54
  Classifier: Topic :: Internet :: WWW/HTTP
56
- Requires-Python: >=3.8
55
+ Requires-Python: >=3.10
57
56
  Description-Content-Type: text/x-rst
58
57
  License-File: LICENSE
59
58
  License-File: AUTHORS
@@ -109,8 +108,8 @@ Please report any security issues to the Django OAuth security team at <django-o
109
108
  Requirements
110
109
  ------------
111
110
 
112
- * Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 or 3.14
113
- * Django 4.2, 5.0, 5.1 or 5.2
111
+ * Python 3.10, 3.11, 3.12, 3.13 or 3.14
112
+ * Django 4.2, 5.0, 5.1, 5.2 or 6.0
114
113
  * oauthlib 3.2.2+
115
114
 
116
115
  Installation
@@ -39,8 +39,8 @@ Please report any security issues to the Django OAuth security team at <django-o
39
39
  Requirements
40
40
  ------------
41
41
 
42
- * Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 or 3.14
43
- * Django 4.2, 5.0, 5.1 or 5.2
42
+ * Python 3.10, 3.11, 3.12, 3.13 or 3.14
43
+ * Django 4.2, 5.0, 5.1, 5.2 or 6.0
44
44
  * oauthlib 3.2.2+
45
45
 
46
46
  Installation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: django-oauth-toolkit
3
- Version: 3.2.0
3
+ Version: 3.3.0
4
4
  Summary: OAuth2 Provider for Django
5
5
  Author: Federico Frenguelli, Massimiliano Pippi
6
6
  Author-email: synasius@gmail.com
@@ -41,19 +41,18 @@ Classifier: Framework :: Django :: 4.2
41
41
  Classifier: Framework :: Django :: 5.0
42
42
  Classifier: Framework :: Django :: 5.1
43
43
  Classifier: Framework :: Django :: 5.2
44
+ Classifier: Framework :: Django :: 6.0
44
45
  Classifier: Intended Audience :: Developers
45
46
  Classifier: License :: OSI Approved :: BSD License
46
47
  Classifier: Operating System :: OS Independent
47
48
  Classifier: Programming Language :: Python :: 3
48
- Classifier: Programming Language :: Python :: 3.8
49
- Classifier: Programming Language :: Python :: 3.9
50
49
  Classifier: Programming Language :: Python :: 3.10
51
50
  Classifier: Programming Language :: Python :: 3.11
52
51
  Classifier: Programming Language :: Python :: 3.12
53
52
  Classifier: Programming Language :: Python :: 3.13
54
53
  Classifier: Programming Language :: Python :: 3.14
55
54
  Classifier: Topic :: Internet :: WWW/HTTP
56
- Requires-Python: >=3.8
55
+ Requires-Python: >=3.10
57
56
  Description-Content-Type: text/x-rst
58
57
  License-File: LICENSE
59
58
  License-File: AUTHORS
@@ -109,8 +108,8 @@ Please report any security issues to the Django OAuth security team at <django-o
109
108
  Requirements
110
109
  ------------
111
110
 
112
- * Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 or 3.14
113
- * Django 4.2, 5.0, 5.1 or 5.2
111
+ * Python 3.10, 3.11, 3.12, 3.13 or 3.14
112
+ * Django 4.2, 5.0, 5.1, 5.2 or 6.0
114
113
  * oauthlib 3.2.2+
115
114
 
116
115
  Installation
@@ -50,6 +50,7 @@ oauth2_provider/migrations/0010_application_allowed_origins.py
50
50
  oauth2_provider/migrations/0011_refreshtoken_token_family.py
51
51
  oauth2_provider/migrations/0012_add_token_checksum.py
52
52
  oauth2_provider/migrations/0013_alter_application_authorization_grant_type_device.py
53
+ oauth2_provider/migrations/0014_alter_help_text.py
53
54
  oauth2_provider/migrations/__init__.py
54
55
  oauth2_provider/templates/oauth2_provider/application_confirm_delete.html
55
56
  oauth2_provider/templates/oauth2_provider/application_detail.html
@@ -0,0 +1 @@
1
+ __version__ = "3.3.0"
@@ -53,6 +53,7 @@ class IDTokenAdmin(admin.ModelAdmin):
53
53
 
54
54
  class RefreshTokenAdmin(admin.ModelAdmin):
55
55
  list_display = ("token", "user", "application")
56
+ list_select_related = ("application", "user")
56
57
  raw_id_fields = ("user", "access_token")
57
58
  search_fields = ("token",) + (("user__email",) if has_email else ())
58
59
  list_filter = ("application",)
@@ -0,0 +1,20 @@
1
+ # Generated by Django 5.2.9 on 2025-12-14 17:02
2
+
3
+ import oauth2_provider.generators
4
+ import oauth2_provider.models
5
+ from django.db import migrations
6
+
7
+
8
+ class Migration(migrations.Migration):
9
+
10
+ dependencies = [
11
+ ('oauth2_provider', '0013_alter_application_authorization_grant_type_device'),
12
+ ]
13
+
14
+ operations = [
15
+ migrations.AlterField(
16
+ model_name='application',
17
+ name='client_secret',
18
+ field=oauth2_provider.models.ClientSecretField(blank=True, db_index=True, default=oauth2_provider.generators.generate_client_secret, help_text='Client secret for authentication', max_length=255),
19
+ ),
20
+ ]
@@ -138,7 +138,7 @@ class AbstractApplication(models.Model):
138
138
  blank=True,
139
139
  default=generate_client_secret,
140
140
  db_index=True,
141
- help_text=_("Hashed on Save. Copy it now if this is a new secret."),
141
+ help_text=_("Client secret for authentication"),
142
142
  )
143
143
  hash_client_secret = models.BooleanField(default=True)
144
144
  name = models.CharField(max_length=255, blank=True)
@@ -562,7 +562,7 @@ class RefreshToken(AbstractRefreshToken):
562
562
  class AbstractIDToken(models.Model):
563
563
  """
564
564
  An IDToken instance represents the actual token to
565
- access user's resources, as in :openid:`2`.
565
+ access user's resources, as defined in the OpenID Connect specification.
566
566
 
567
567
  Fields:
568
568
 
@@ -736,10 +736,12 @@ class DeviceCodeResponse:
736
736
  verification_uri_complete: Optional[Union[str, Callable]] = None
737
737
 
738
738
 
739
- def create_device_grant(device_request: DeviceRequest, device_response: DeviceCodeResponse) -> DeviceGrant:
739
+ def create_device_grant(
740
+ device_request: DeviceRequest, device_response: DeviceCodeResponse
741
+ ) -> AbstractDeviceGrant:
740
742
  now = datetime.now(tz=dt_timezone.utc)
741
743
 
742
- return DeviceGrant.objects.create(
744
+ return get_device_grant_model().objects.create(
743
745
  client_id=device_request.client_id,
744
746
  device_code=device_response.device_code,
745
747
  user_code=device_response.user_code,
@@ -217,13 +217,16 @@ class OAuth2Validator(RequestValidator):
217
217
  if request.client:
218
218
  # check for cached client, to save the db hit if this has already been loaded
219
219
  if not isinstance(request.client, Application):
220
- # resetting request.client (client_id=%r): not an Application, something else set request.client erroneously
220
+ # resetting request.client (client_id=%r):
221
+ # not an Application, something else set request.client erroneously
221
222
  request.client = None
222
223
  elif request.client.client_id != client_id:
223
- # resetting request.client (client_id=%r): request.client.client_id does not match the given client_id
224
+ # resetting request.client (client_id=%r):
225
+ # request.client.client_id does not match the given client_id
224
226
  request.client = None
225
227
  elif not request.client.is_usable(request):
226
- # resetting request.client (client_id=%r): request.client is a valid Application, but is not usable
228
+ # resetting request.client (client_id=%r):
229
+ # request.client is a valid Application, but is not usable
227
230
  request.client = None
228
231
  else:
229
232
  # request.client is a valid Application, reusing it
@@ -5,7 +5,12 @@
5
5
  <title>Accept or Deny</title>
6
6
  </head>
7
7
  <body>
8
- <h1>Please choose an action:</h1>
8
+ <h1>{{ application.name }} requests access to the following scopes:</h1>
9
+ <ul>
10
+ {% for scope in scopes_descriptions %}
11
+ <li>{{ scope }}</li>
12
+ {% endfor %}
13
+ </ul>
9
14
  <form method="post">
10
15
  {% csrf_token %}
11
16
  <button type="submit" name="action" value="accept">Accept</button>
@@ -96,7 +96,10 @@ def set_oauthlib_user_to_device_request_user(request: Request) -> None:
96
96
  """
97
97
  # Since this function is used in the settings module, it will lead to circular imports
98
98
  # since django isn't fully initialised yet when settings run
99
- from oauth2_provider.models import DeviceGrant, get_device_grant_model
99
+ from oauth2_provider.models import AbstractDeviceGrant, get_device_grant_model
100
100
 
101
- device: DeviceGrant = get_device_grant_model().objects.get(device_code=request._params["device_code"])
101
+ device: AbstractDeviceGrant = get_device_grant_model().objects.get(
102
+ device_code=request._params["device_code"]
103
+ )
102
104
  request.user = device.user
105
+ request.scopes = device.scope.split() if device.scope else []
@@ -15,13 +15,11 @@ from django.views.decorators.debug import sensitive_post_parameters
15
15
  from django.views.generic import FormView, View
16
16
  from oauthlib.oauth2.rfc8628 import errors as rfc8628_errors
17
17
 
18
- from oauth2_provider.models import DeviceGrant
19
-
20
18
  from ..compat import login_not_required
21
19
  from ..exceptions import OAuthToolkitError
22
20
  from ..forms import AllowForm
23
21
  from ..http import OAuth2ResponseRedirect
24
- from ..models import get_access_token_model, get_application_model
22
+ from ..models import get_access_token_model, get_application_model, get_device_grant_model
25
23
  from ..scopes import get_scopes_backend
26
24
  from ..settings import oauth2_settings
27
25
  from ..signals import app_authorized
@@ -317,9 +315,10 @@ class TokenView(OAuthLibMixin, View):
317
315
  def device_flow_token_response(
318
316
  self, request: http.HttpRequest, device_code: str, *args, **kwargs
319
317
  ) -> http.HttpResponse:
318
+ device_grant_model = get_device_grant_model()
320
319
  try:
321
- device = DeviceGrant.objects.get(device_code=device_code)
322
- except DeviceGrant.DoesNotExist:
320
+ device = device_grant_model.objects.get(device_code=device_code)
321
+ except device_grant_model.DoesNotExist:
323
322
  # The RFC does not mention what to return when the device is not found,
324
323
  # but to keep it consistent with the other errors, we return the error
325
324
  # in json format with an "error" key and the value formatted in the same
@@ -8,16 +8,20 @@ from django.urls import reverse
8
8
  from django.utils.decorators import method_decorator
9
9
  from django.views.decorators.csrf import csrf_exempt
10
10
  from django.views.generic import DetailView, FormView, View
11
+ from oauthlib.common import Request as OAuthlibRequest
12
+ from oauthlib.common import urlencode
11
13
  from oauthlib.oauth2 import DeviceApplicationServer
12
14
 
13
15
  from oauth2_provider.compat import login_not_required
14
16
  from oauth2_provider.models import (
17
+ AbstractDeviceGrant,
15
18
  DeviceCodeResponse,
16
- DeviceGrant,
17
19
  DeviceRequest,
18
20
  create_device_grant,
21
+ get_application_model,
19
22
  get_device_grant_model,
20
23
  )
24
+ from oauth2_provider.scopes import get_scopes_backend
21
25
  from oauth2_provider.views.mixins import OAuthLibMixin
22
26
 
23
27
 
@@ -32,7 +36,31 @@ class DeviceAuthorizationView(OAuthLibMixin, View):
32
36
  if status != 200:
33
37
  return http.JsonResponse(data=json.loads(response), status=status, headers=headers)
34
38
 
35
- device_request = DeviceRequest(client_id=request.POST["client_id"], scope=request.POST.get("scope"))
39
+ client_id = request.POST["client_id"]
40
+ requested_scope = request.POST.get("scope", "").strip()
41
+ if requested_scope:
42
+ scope = requested_scope
43
+ else:
44
+ Application = get_application_model()
45
+ try:
46
+ application = Application.objects.get(client_id=client_id)
47
+ except Application.DoesNotExist:
48
+ return http.JsonResponse(
49
+ {"error": "invalid_client", "error_description": "No application found for client_id."},
50
+ status=401,
51
+ headers=headers,
52
+ )
53
+ core = self.get_oauthlib_core()
54
+ uri = request.build_absolute_uri()
55
+ http_method = request.method
56
+ body = urlencode(core.extract_body(request))
57
+ req_headers = core.extract_headers(request)
58
+ oauthlib_request = OAuthlibRequest(uri, http_method=http_method, body=body, headers=req_headers)
59
+ oauthlib_request.client_id = client_id
60
+ oauthlib_request.client = application
61
+ validator = core.server.request_validator
62
+ scope = " ".join(validator.get_default_scopes(client_id, oauthlib_request))
63
+ device_request = DeviceRequest(client_id=client_id, scope=scope)
36
64
  device_response = DeviceCodeResponse(**response)
37
65
  create_device_grant(device_request, device_response)
38
66
 
@@ -57,9 +85,10 @@ class DeviceGrantForm(forms.Form):
57
85
  """
58
86
  cleaned_data = super().clean()
59
87
  user_code: str = cleaned_data["user_code"]
88
+ device_grant_model = get_device_grant_model()
60
89
  try:
61
- device_grant: DeviceGrant = get_device_grant_model().objects.get(user_code=user_code)
62
- except DeviceGrant.DoesNotExist:
90
+ device_grant: AbstractDeviceGrant = device_grant_model.objects.get(user_code=user_code)
91
+ except device_grant_model.DoesNotExist:
63
92
  raise ValidationError("Incorrect user code", code="incorrect_user_code")
64
93
 
65
94
  if device_grant.is_expired():
@@ -99,6 +128,11 @@ class DeviceUserCodeView(LoginRequiredMixin, FormView):
99
128
  },
100
129
  )
101
130
 
131
+ def get_initial(self):
132
+ initial = super().get_initial()
133
+ initial["user_code"] = self.request.GET.get("user_code", "")
134
+ return initial
135
+
102
136
  def form_valid(self, form):
103
137
  """
104
138
  Sets the device_grant on the instance so that it can be accessed
@@ -106,7 +140,7 @@ class DeviceUserCodeView(LoginRequiredMixin, FormView):
106
140
  get_success_url, redirecting to the URL with the URL params pointing
107
141
  to the current device.
108
142
  """
109
- device_grant: DeviceGrant = form.cleaned_data["device_grant"]
143
+ device_grant: AbstractDeviceGrant = form.cleaned_data["device_grant"]
110
144
 
111
145
  device_grant.user = self.request.user
112
146
  device_grant.save(update_fields=["user"])
@@ -136,14 +170,20 @@ class DeviceConfirmView(LoginRequiredMixin, FormView):
136
170
  """
137
171
  Returns the DeviceGrant object in the AUTHORIZATION_PENDING state identified
138
172
  by the slugs client_id and user_code. Raises Http404 if not found.
173
+
174
+ The result is cached on the instance to avoid redundant queries within the
175
+ same request (e.g. get() validates and get_context_data() reads scopes).
139
176
  """
140
- client_id, user_code = self.kwargs.get("client_id"), self.kwargs.get("user_code")
141
- return get_object_or_404(
142
- DeviceGrant,
143
- client_id=client_id,
144
- user_code=user_code,
145
- status=DeviceGrant.AUTHORIZATION_PENDING,
146
- )
177
+ if not hasattr(self, "_device_grant"):
178
+ client_id, user_code = self.kwargs.get("client_id"), self.kwargs.get("user_code")
179
+ model = get_device_grant_model()
180
+ self._device_grant = get_object_or_404(
181
+ model,
182
+ client_id=client_id,
183
+ user_code=user_code,
184
+ status=model.AUTHORIZATION_PENDING,
185
+ )
186
+ return self._device_grant
147
187
 
148
188
  def get_success_url(self):
149
189
  return reverse(
@@ -182,15 +222,30 @@ class DeviceConfirmView(LoginRequiredMixin, FormView):
182
222
  else:
183
223
  return http.HttpResponseBadRequest()
184
224
 
225
+ def get_context_data(self, **kwargs):
226
+ context = super().get_context_data(**kwargs)
227
+ client_id = self.kwargs.get("client_id")
228
+ context["application"] = get_object_or_404(get_application_model(), client_id=client_id)
229
+
230
+ device = self.get_object()
231
+ all_scopes = get_scopes_backend().get_all_scopes()
232
+ scopes = device.scope.split() if device.scope is not None else []
233
+ context["scopes"] = scopes
234
+ context["scopes_descriptions"] = [all_scopes.get(scope, scope) for scope in scopes]
235
+
236
+ return context
237
+
185
238
 
186
239
  class DeviceGrantStatusView(LoginRequiredMixin, DetailView):
187
240
  """
188
241
  The view to display the status of a DeviceGrant.
189
242
  """
190
243
 
191
- model = DeviceGrant
192
244
  template_name = "oauth2_provider/device/device_grant_status.html"
193
245
 
246
+ def get_queryset(self):
247
+ return get_device_grant_model().objects.all()
248
+
194
249
  def get_object(self):
195
250
  client_id, user_code = self.kwargs.get("client_id"), self.kwargs.get("user_code")
196
- return get_object_or_404(DeviceGrant, client_id=client_id, user_code=user_code)
251
+ return get_object_or_404(self.get_queryset(), client_id=client_id, user_code=user_code)
@@ -128,7 +128,7 @@ class JwksInfoView(OIDCOnlyMixin, View):
128
128
  response = JsonResponse({"keys": keys})
129
129
  response["Access-Control-Allow-Origin"] = "*"
130
130
  response["Cache-Control"] = (
131
- "Cache-Control: public, "
131
+ "public, "
132
132
  + f"max-age={oauth2_settings.OIDC_JWKS_MAX_AGE_SECONDS}, "
133
133
  + f"stale-while-revalidate={oauth2_settings.OIDC_JWKS_MAX_AGE_SECONDS}, "
134
134
  + f"stale-if-error={oauth2_settings.OIDC_JWKS_MAX_AGE_SECONDS}"
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "django-oauth-toolkit"
7
7
  dynamic = ["version"]
8
- requires-python = ">=3.8"
8
+ requires-python = ">=3.10"
9
9
  authors = [
10
10
  {name = "Federico Frenguelli"},
11
11
  {name = "Massimiliano Pippi"},
@@ -23,12 +23,11 @@ classifiers = [
23
23
  "Framework :: Django :: 5.0",
24
24
  "Framework :: Django :: 5.1",
25
25
  "Framework :: Django :: 5.2",
26
+ "Framework :: Django :: 6.0",
26
27
  "Intended Audience :: Developers",
27
28
  "License :: OSI Approved :: BSD License",
28
29
  "Operating System :: OS Independent",
29
30
  "Programming Language :: Python :: 3",
30
- "Programming Language :: Python :: 3.8",
31
- "Programming Language :: Python :: 3.9",
32
31
  "Programming Language :: Python :: 3.10",
33
32
  "Programming Language :: Python :: 3.11",
34
33
  "Programming Language :: Python :: 3.12",
@@ -58,9 +57,12 @@ Repository = "https://github.com/django-oauth/django-oauth-toolkit"
58
57
  [tool.setuptools.dynamic]
59
58
  version = {attr = "oauth2_provider.__version__"}
60
59
 
60
+ [tool.setuptools.packages.find]
61
+ include = ["oauth2_provider", "oauth2_provider.*"]
62
+
61
63
  # Ref: https://github.com/codespell-project/codespell#using-a-config-file
62
64
  [tool.codespell]
63
- skip = '.git,package-lock.json,locale,AUTHORS,tox.ini'
65
+ skip = '.git,package-lock.json,locale,AUTHORS,tox.ini,rfcs'
64
66
  check-hidden = true
65
67
  ignore-regex = '.*pragma: codespell-ignore.*'
66
68
  ignore-words-list = 'assertIn'
@@ -87,7 +89,7 @@ markers = [
87
89
 
88
90
  [tool.ruff]
89
91
  line-length = 110
90
- exclude = [".tox", "build/", "dist/", "docs/", "oauth2_provider/migrations/", "tests/migrations/", "manage.py"]
92
+ exclude = [".tox", "build/", "dist/", "docs/", "oauth2_provider/migrations/", "tests/migrations/", "manage.py", "rfcs/"]
91
93
 
92
94
  [tool.ruff.lint]
93
95
  select = ["E", "F", "I", "Q", "W"]