django-oauth-toolkit 3.4.0__tar.gz → 3.4.2__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.
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/AUTHORS +1 -0
- {django_oauth_toolkit-3.4.0/django_oauth_toolkit.egg-info → django_oauth_toolkit-3.4.2}/PKG-INFO +33 -14
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/README.rst +30 -11
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2/django_oauth_toolkit.egg-info}/PKG-INFO +33 -14
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/django_oauth_toolkit.egg-info/SOURCES.txt +4 -0
- django_oauth_toolkit-3.4.2/oauth2_provider/__init__.py +1 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/admin.py +48 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/checks.py +48 -1
- django_oauth_toolkit-3.4.2/oauth2_provider/compat.py +25 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/contrib/rest_framework/permissions.py +15 -6
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/forms.py +21 -0
- django_oauth_toolkit-3.4.2/oauth2_provider/management/commands/cleartokens.py +20 -0
- django_oauth_toolkit-3.4.2/oauth2_provider/migrations/0021_translatable_field_labels.py +527 -0
- django_oauth_toolkit-3.4.2/oauth2_provider/migrations/0022_refreshtoken_token_family_index.py +23 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/models.py +509 -103
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/oauth2_backends.py +26 -1
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/oauth2_validators.py +190 -38
- django_oauth_toolkit-3.4.2/oauth2_provider/static/oauth2_provider/css/oauth2_provider.css +200 -0
- django_oauth_toolkit-3.4.2/oauth2_provider/templates/oauth2_provider/base.html +23 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/utils.py +42 -3
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/validators.py +47 -2
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/base.py +32 -19
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/device.py +18 -3
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/dynamic_client_registration.py +83 -43
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/token.py +17 -1
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/pyproject.toml +2 -2
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_admin.py +128 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_application_views.py +107 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_authorization_code.py +372 -3
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_bcp_rfc9700.py +27 -1
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_commands.py +24 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_dcr_views.py +80 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_device.py +605 -46
- django_oauth_toolkit-3.4.2/tests/test_django_checks.py +70 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_hybrid.py +5 -3
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_implicit.py +1 -1
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_models.py +650 -2
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_oauth2_backends.py +10 -1
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_oauth2_validators.py +284 -2
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_rest_framework.py +17 -6
- django_oauth_toolkit-3.4.2/tests/test_templates.py +72 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_token_revocation.py +132 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_token_view.py +55 -1
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_validators.py +107 -0
- django_oauth_toolkit-3.4.0/oauth2_provider/__init__.py +0 -1
- django_oauth_toolkit-3.4.0/oauth2_provider/compat.py +0 -15
- django_oauth_toolkit-3.4.0/oauth2_provider/management/commands/cleartokens.py +0 -10
- django_oauth_toolkit-3.4.0/oauth2_provider/templates/oauth2_provider/base.html +0 -48
- django_oauth_toolkit-3.4.0/tests/test_django_checks.py +0 -20
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/LICENSE +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/MANIFEST.in +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/django_oauth_toolkit.egg-info/dependency_links.txt +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/django_oauth_toolkit.egg-info/requires.txt +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/django_oauth_toolkit.egg-info/top_level.txt +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/apps.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/backends.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/bcp.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/cimd.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/contrib/__init__.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/contrib/ninja/__init__.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/contrib/ninja/security.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/contrib/rest_framework/__init__.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/contrib/rest_framework/authentication.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/dcr.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/decorators.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/exceptions.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/generators.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/http.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/management/__init__.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/management/commands/__init__.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/management/commands/clearcimdapplications.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/management/commands/createapplication.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/middleware.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0001_initial.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0002_auto_20190406_1805.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0003_auto_20201211_1314.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0004_auto_20200902_2022.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0005_auto_20211222_2352.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0006_alter_application_client_secret.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0007_application_post_logout_redirect_uris.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0008_alter_accesstoken_token.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0009_add_hash_client_secret.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0010_application_allowed_origins.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0011_refreshtoken_token_family.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0012_add_token_checksum.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0013_alter_application_authorization_grant_type_device.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0014_alter_help_text.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0015_refreshtoken_token_checksum.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0016_alter_devicegrant_scope.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0017_application_dcr_created.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0018_resource_indicators.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0019_application_registration_source.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/0020_cimd_application_fields.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/migrations/__init__.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/scopes.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/settings.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/signals.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/static/oauth2_provider/js/application_form.js +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/application_confirm_delete.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/application_detail.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/application_form.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/application_list.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/application_registration_form.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/authorize.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/authorized-token-delete.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/authorized-tokens.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/device/accept_deny.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/device/device_grant_status.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/device/user_code.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/templates/oauth2_provider/logout_confirm.html +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/urls.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/__init__.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/application.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/generic.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/introspect.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/metadata.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/mixins.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/views/oidc.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/oauth2_provider/www_authenticate.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/setup.cfg +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_auth_backends.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_cimd.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_client_credential.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_decorators.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_generator.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_introspection_auth.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_introspection_view.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_migration_0012_hang.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_migration_db_alias.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_mixins.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_ninja.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_oauth2_provider_middleware.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_oidc_views.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_password.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_resource_validators.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_rfc8707_integration.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_scopes.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_scopes_backend.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_settings.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_token_endpoint_cors.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_ui_locales.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_utils.py +0 -0
- {django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/tests/test_www_authenticate.py +0 -0
{django_oauth_toolkit-3.4.0/django_oauth_toolkit.egg-info → django_oauth_toolkit-3.4.2}/PKG-INFO
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-oauth-toolkit
|
|
3
|
-
Version: 3.4.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 3.4.2
|
|
4
|
+
Summary: OAuth 2.0 authorization server for Django
|
|
5
5
|
Author: Federico Frenguelli, Massimiliano Pippi
|
|
6
6
|
Author-email: synasius@gmail.com
|
|
7
7
|
License: Copyright (c) 2013, Massimiliano Pippi, Federico Frenguelli and contributors
|
|
@@ -33,7 +33,7 @@ License: Copyright (c) 2013, Massimiliano Pippi, Federico Frenguelli and contrib
|
|
|
33
33
|
|
|
34
34
|
Project-URL: Homepage, https://django-oauth-toolkit.readthedocs.io/
|
|
35
35
|
Project-URL: Repository, https://github.com/django-oauth/django-oauth-toolkit
|
|
36
|
-
Keywords: django,oauth,oauth2,oauthlib
|
|
36
|
+
Keywords: django,oauth,oauth2,oauthlib,authorization-server,oidc,mcp,pkce
|
|
37
37
|
Classifier: Development Status :: 5 - Production/Stable
|
|
38
38
|
Classifier: Environment :: Web Environment
|
|
39
39
|
Classifier: Framework :: Django
|
|
@@ -97,9 +97,13 @@ Django OAuth Toolkit
|
|
|
97
97
|
.. image:: https://badge.fury.io/py/django-oauth-toolkit.svg
|
|
98
98
|
:target: http://badge.fury.io/py/django-oauth-toolkit
|
|
99
99
|
|
|
100
|
-
.. image:: https://github.com/django-oauth/django-oauth-toolkit/workflows/
|
|
101
|
-
:target: https://github.com/django-oauth/django-oauth-toolkit/actions
|
|
102
|
-
:alt:
|
|
100
|
+
.. image:: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml/badge.svg?branch=master&event=push
|
|
101
|
+
:target: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml?query=branch%3Amaster
|
|
102
|
+
:alt: Tests (master)
|
|
103
|
+
|
|
104
|
+
.. image:: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml/badge.svg?branch=3.4.x&event=push
|
|
105
|
+
:target: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml?query=branch%3A3.4.x
|
|
106
|
+
:alt: Tests (3.4.x)
|
|
103
107
|
|
|
104
108
|
.. image:: https://codecov.io/gh/django-oauth/django-oauth-toolkit/branch/master/graph/badge.svg
|
|
105
109
|
:target: https://codecov.io/gh/django-oauth/django-oauth-toolkit
|
|
@@ -113,19 +117,34 @@ Django OAuth Toolkit
|
|
|
113
117
|
:target: https://pypi.org/project/django-oauth-toolkit/
|
|
114
118
|
:alt: Supported Django versions
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Django OAuth Toolkit
|
|
121
|
-
|
|
120
|
+
Django OAuth Toolkit is an OAuth 2.0 authorization server for teams already running Django.
|
|
121
|
+
It provides, out of the box, the endpoints, models, and logic to issue and manage OAuth2 tokens
|
|
122
|
+
from your existing Django project, instead of standing up and operating a separate service.
|
|
123
|
+
|
|
124
|
+
As of 3.4.0, Django OAuth Toolkit supports the authorization server role required by the
|
|
125
|
+
Model Context Protocol (MCP) authorization specification: PKCE is required by default, and the
|
|
126
|
+
authorization server metadata (RFC 8414) and protected resource metadata (RFC 9728) discovery
|
|
127
|
+
endpoints are included in the default URLconf. Dynamic Client Registration (RFC 7591/7592) and
|
|
128
|
+
Client ID Metadata Documents can be enabled with the ``DCR_ENABLED`` and ``CIMD_ENABLED`` settings.
|
|
129
|
+
See the
|
|
130
|
+
`3.4.0 release discussion <https://github.com/django-oauth/django-oauth-toolkit/discussions/1775>`_
|
|
131
|
+
for the supported specifications and current gaps.
|
|
132
|
+
|
|
133
|
+
Django OAuth Toolkit can also act as a resource server to protect a Django or Django REST
|
|
134
|
+
Framework API with OAuth2. It makes extensive use of the excellent
|
|
122
135
|
`OAuthLib <https://github.com/idan/oauthlib>`_, so that everything is
|
|
123
136
|
`rfc-compliant <https://rfc-editor.org/rfc/rfc6749.html>`_.
|
|
124
137
|
|
|
125
138
|
Reporting security issues
|
|
126
139
|
-------------------------
|
|
127
140
|
|
|
128
|
-
Please
|
|
141
|
+
Please use GitHub's `private vulnerability reporting form
|
|
142
|
+
<https://github.com/django-oauth/django-oauth-toolkit/security/advisories/new>`_
|
|
143
|
+
and follow the repository `security policy
|
|
144
|
+
<https://github.com/django-oauth/django-oauth-toolkit/security/policy>`_. Do not
|
|
145
|
+
file a public issue or pull request for an undisclosed vulnerability. If private
|
|
146
|
+
reporting is unavailable, email the `Django OAuth security team
|
|
147
|
+
<mailto:django-oauth-security@googlegroups.com>`_.
|
|
129
148
|
|
|
130
149
|
Requirements
|
|
131
150
|
------------
|
|
@@ -151,7 +170,7 @@ Add ``oauth2_provider`` to your ``INSTALLED_APPS``
|
|
|
151
170
|
)
|
|
152
171
|
|
|
153
172
|
|
|
154
|
-
If you need an
|
|
173
|
+
If you need an OAuth 2.0 authorization server you'll want to add the following to your ``urls.py``.
|
|
155
174
|
|
|
156
175
|
.. code-block:: python
|
|
157
176
|
|
|
@@ -6,9 +6,13 @@ Django OAuth Toolkit
|
|
|
6
6
|
.. image:: https://badge.fury.io/py/django-oauth-toolkit.svg
|
|
7
7
|
:target: http://badge.fury.io/py/django-oauth-toolkit
|
|
8
8
|
|
|
9
|
-
.. image:: https://github.com/django-oauth/django-oauth-toolkit/workflows/
|
|
10
|
-
:target: https://github.com/django-oauth/django-oauth-toolkit/actions
|
|
11
|
-
:alt:
|
|
9
|
+
.. image:: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml/badge.svg?branch=master&event=push
|
|
10
|
+
:target: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml?query=branch%3Amaster
|
|
11
|
+
:alt: Tests (master)
|
|
12
|
+
|
|
13
|
+
.. image:: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml/badge.svg?branch=3.4.x&event=push
|
|
14
|
+
:target: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml?query=branch%3A3.4.x
|
|
15
|
+
:alt: Tests (3.4.x)
|
|
12
16
|
|
|
13
17
|
.. image:: https://codecov.io/gh/django-oauth/django-oauth-toolkit/branch/master/graph/badge.svg
|
|
14
18
|
:target: https://codecov.io/gh/django-oauth/django-oauth-toolkit
|
|
@@ -22,19 +26,34 @@ Django OAuth Toolkit
|
|
|
22
26
|
:target: https://pypi.org/project/django-oauth-toolkit/
|
|
23
27
|
:alt: Supported Django versions
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Django OAuth Toolkit
|
|
30
|
-
|
|
29
|
+
Django OAuth Toolkit is an OAuth 2.0 authorization server for teams already running Django.
|
|
30
|
+
It provides, out of the box, the endpoints, models, and logic to issue and manage OAuth2 tokens
|
|
31
|
+
from your existing Django project, instead of standing up and operating a separate service.
|
|
32
|
+
|
|
33
|
+
As of 3.4.0, Django OAuth Toolkit supports the authorization server role required by the
|
|
34
|
+
Model Context Protocol (MCP) authorization specification: PKCE is required by default, and the
|
|
35
|
+
authorization server metadata (RFC 8414) and protected resource metadata (RFC 9728) discovery
|
|
36
|
+
endpoints are included in the default URLconf. Dynamic Client Registration (RFC 7591/7592) and
|
|
37
|
+
Client ID Metadata Documents can be enabled with the ``DCR_ENABLED`` and ``CIMD_ENABLED`` settings.
|
|
38
|
+
See the
|
|
39
|
+
`3.4.0 release discussion <https://github.com/django-oauth/django-oauth-toolkit/discussions/1775>`_
|
|
40
|
+
for the supported specifications and current gaps.
|
|
41
|
+
|
|
42
|
+
Django OAuth Toolkit can also act as a resource server to protect a Django or Django REST
|
|
43
|
+
Framework API with OAuth2. It makes extensive use of the excellent
|
|
31
44
|
`OAuthLib <https://github.com/idan/oauthlib>`_, so that everything is
|
|
32
45
|
`rfc-compliant <https://rfc-editor.org/rfc/rfc6749.html>`_.
|
|
33
46
|
|
|
34
47
|
Reporting security issues
|
|
35
48
|
-------------------------
|
|
36
49
|
|
|
37
|
-
Please
|
|
50
|
+
Please use GitHub's `private vulnerability reporting form
|
|
51
|
+
<https://github.com/django-oauth/django-oauth-toolkit/security/advisories/new>`_
|
|
52
|
+
and follow the repository `security policy
|
|
53
|
+
<https://github.com/django-oauth/django-oauth-toolkit/security/policy>`_. Do not
|
|
54
|
+
file a public issue or pull request for an undisclosed vulnerability. If private
|
|
55
|
+
reporting is unavailable, email the `Django OAuth security team
|
|
56
|
+
<mailto:django-oauth-security@googlegroups.com>`_.
|
|
38
57
|
|
|
39
58
|
Requirements
|
|
40
59
|
------------
|
|
@@ -60,7 +79,7 @@ Add ``oauth2_provider`` to your ``INSTALLED_APPS``
|
|
|
60
79
|
)
|
|
61
80
|
|
|
62
81
|
|
|
63
|
-
If you need an
|
|
82
|
+
If you need an OAuth 2.0 authorization server you'll want to add the following to your ``urls.py``.
|
|
64
83
|
|
|
65
84
|
.. code-block:: python
|
|
66
85
|
|
{django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2/django_oauth_toolkit.egg-info}/PKG-INFO
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-oauth-toolkit
|
|
3
|
-
Version: 3.4.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 3.4.2
|
|
4
|
+
Summary: OAuth 2.0 authorization server for Django
|
|
5
5
|
Author: Federico Frenguelli, Massimiliano Pippi
|
|
6
6
|
Author-email: synasius@gmail.com
|
|
7
7
|
License: Copyright (c) 2013, Massimiliano Pippi, Federico Frenguelli and contributors
|
|
@@ -33,7 +33,7 @@ License: Copyright (c) 2013, Massimiliano Pippi, Federico Frenguelli and contrib
|
|
|
33
33
|
|
|
34
34
|
Project-URL: Homepage, https://django-oauth-toolkit.readthedocs.io/
|
|
35
35
|
Project-URL: Repository, https://github.com/django-oauth/django-oauth-toolkit
|
|
36
|
-
Keywords: django,oauth,oauth2,oauthlib
|
|
36
|
+
Keywords: django,oauth,oauth2,oauthlib,authorization-server,oidc,mcp,pkce
|
|
37
37
|
Classifier: Development Status :: 5 - Production/Stable
|
|
38
38
|
Classifier: Environment :: Web Environment
|
|
39
39
|
Classifier: Framework :: Django
|
|
@@ -97,9 +97,13 @@ Django OAuth Toolkit
|
|
|
97
97
|
.. image:: https://badge.fury.io/py/django-oauth-toolkit.svg
|
|
98
98
|
:target: http://badge.fury.io/py/django-oauth-toolkit
|
|
99
99
|
|
|
100
|
-
.. image:: https://github.com/django-oauth/django-oauth-toolkit/workflows/
|
|
101
|
-
:target: https://github.com/django-oauth/django-oauth-toolkit/actions
|
|
102
|
-
:alt:
|
|
100
|
+
.. image:: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml/badge.svg?branch=master&event=push
|
|
101
|
+
:target: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml?query=branch%3Amaster
|
|
102
|
+
:alt: Tests (master)
|
|
103
|
+
|
|
104
|
+
.. image:: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml/badge.svg?branch=3.4.x&event=push
|
|
105
|
+
:target: https://github.com/django-oauth/django-oauth-toolkit/actions/workflows/test.yml?query=branch%3A3.4.x
|
|
106
|
+
:alt: Tests (3.4.x)
|
|
103
107
|
|
|
104
108
|
.. image:: https://codecov.io/gh/django-oauth/django-oauth-toolkit/branch/master/graph/badge.svg
|
|
105
109
|
:target: https://codecov.io/gh/django-oauth/django-oauth-toolkit
|
|
@@ -113,19 +117,34 @@ Django OAuth Toolkit
|
|
|
113
117
|
:target: https://pypi.org/project/django-oauth-toolkit/
|
|
114
118
|
:alt: Supported Django versions
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Django OAuth Toolkit
|
|
121
|
-
|
|
120
|
+
Django OAuth Toolkit is an OAuth 2.0 authorization server for teams already running Django.
|
|
121
|
+
It provides, out of the box, the endpoints, models, and logic to issue and manage OAuth2 tokens
|
|
122
|
+
from your existing Django project, instead of standing up and operating a separate service.
|
|
123
|
+
|
|
124
|
+
As of 3.4.0, Django OAuth Toolkit supports the authorization server role required by the
|
|
125
|
+
Model Context Protocol (MCP) authorization specification: PKCE is required by default, and the
|
|
126
|
+
authorization server metadata (RFC 8414) and protected resource metadata (RFC 9728) discovery
|
|
127
|
+
endpoints are included in the default URLconf. Dynamic Client Registration (RFC 7591/7592) and
|
|
128
|
+
Client ID Metadata Documents can be enabled with the ``DCR_ENABLED`` and ``CIMD_ENABLED`` settings.
|
|
129
|
+
See the
|
|
130
|
+
`3.4.0 release discussion <https://github.com/django-oauth/django-oauth-toolkit/discussions/1775>`_
|
|
131
|
+
for the supported specifications and current gaps.
|
|
132
|
+
|
|
133
|
+
Django OAuth Toolkit can also act as a resource server to protect a Django or Django REST
|
|
134
|
+
Framework API with OAuth2. It makes extensive use of the excellent
|
|
122
135
|
`OAuthLib <https://github.com/idan/oauthlib>`_, so that everything is
|
|
123
136
|
`rfc-compliant <https://rfc-editor.org/rfc/rfc6749.html>`_.
|
|
124
137
|
|
|
125
138
|
Reporting security issues
|
|
126
139
|
-------------------------
|
|
127
140
|
|
|
128
|
-
Please
|
|
141
|
+
Please use GitHub's `private vulnerability reporting form
|
|
142
|
+
<https://github.com/django-oauth/django-oauth-toolkit/security/advisories/new>`_
|
|
143
|
+
and follow the repository `security policy
|
|
144
|
+
<https://github.com/django-oauth/django-oauth-toolkit/security/policy>`_. Do not
|
|
145
|
+
file a public issue or pull request for an undisclosed vulnerability. If private
|
|
146
|
+
reporting is unavailable, email the `Django OAuth security team
|
|
147
|
+
<mailto:django-oauth-security@googlegroups.com>`_.
|
|
129
148
|
|
|
130
149
|
Requirements
|
|
131
150
|
------------
|
|
@@ -151,7 +170,7 @@ Add ``oauth2_provider`` to your ``INSTALLED_APPS``
|
|
|
151
170
|
)
|
|
152
171
|
|
|
153
172
|
|
|
154
|
-
If you need an
|
|
173
|
+
If you need an OAuth 2.0 authorization server you'll want to add the following to your ``urls.py``.
|
|
155
174
|
|
|
156
175
|
.. code-block:: python
|
|
157
176
|
|
{django_oauth_toolkit-3.4.0 → django_oauth_toolkit-3.4.2}/django_oauth_toolkit.egg-info/SOURCES.txt
RENAMED
|
@@ -64,7 +64,10 @@ oauth2_provider/migrations/0017_application_dcr_created.py
|
|
|
64
64
|
oauth2_provider/migrations/0018_resource_indicators.py
|
|
65
65
|
oauth2_provider/migrations/0019_application_registration_source.py
|
|
66
66
|
oauth2_provider/migrations/0020_cimd_application_fields.py
|
|
67
|
+
oauth2_provider/migrations/0021_translatable_field_labels.py
|
|
68
|
+
oauth2_provider/migrations/0022_refreshtoken_token_family_index.py
|
|
67
69
|
oauth2_provider/migrations/__init__.py
|
|
70
|
+
oauth2_provider/static/oauth2_provider/css/oauth2_provider.css
|
|
68
71
|
oauth2_provider/static/oauth2_provider/js/application_form.js
|
|
69
72
|
oauth2_provider/templates/oauth2_provider/application_confirm_delete.html
|
|
70
73
|
oauth2_provider/templates/oauth2_provider/application_detail.html
|
|
@@ -123,6 +126,7 @@ tests/test_rfc8707_integration.py
|
|
|
123
126
|
tests/test_scopes.py
|
|
124
127
|
tests/test_scopes_backend.py
|
|
125
128
|
tests/test_settings.py
|
|
129
|
+
tests/test_templates.py
|
|
126
130
|
tests/test_token_endpoint_cors.py
|
|
127
131
|
tests/test_token_revocation.py
|
|
128
132
|
tests/test_token_view.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "3.4.2"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from django.contrib import admin
|
|
2
2
|
from django.contrib.auth import get_user_model
|
|
3
|
+
from django.utils.translation import ngettext
|
|
3
4
|
|
|
4
5
|
from oauth2_provider.forms import ApplicationForm
|
|
5
6
|
from oauth2_provider.models import (
|
|
@@ -13,6 +14,7 @@ from oauth2_provider.models import (
|
|
|
13
14
|
get_id_token_model,
|
|
14
15
|
get_refresh_token_admin_class,
|
|
15
16
|
get_refresh_token_model,
|
|
17
|
+
revoke_access_token,
|
|
16
18
|
)
|
|
17
19
|
|
|
18
20
|
|
|
@@ -85,12 +87,36 @@ class AccessTokenAdmin(admin.ModelAdmin):
|
|
|
85
87
|
# Search by non-secret identifiers only; never by the token itself.
|
|
86
88
|
search_fields = ("application__client_id", "application__name") + USER_SEARCH_FIELDS
|
|
87
89
|
list_filter = ("application",)
|
|
90
|
+
actions = ("revoke_tokens",)
|
|
88
91
|
|
|
89
92
|
def has_add_permission(self, request):
|
|
90
93
|
# Access tokens are issued by the OAuth flows, not hand-created in the admin.
|
|
91
94
|
# Disabling add also removes the add form's editable (cleartext) token field.
|
|
92
95
|
return False
|
|
93
96
|
|
|
97
|
+
def has_delete_permission(self, request, obj=None):
|
|
98
|
+
# Invalidate access tokens with the "Revoke selected access tokens" action, not a raw
|
|
99
|
+
# delete. Deleting an access token row leaves its bound refresh token behind
|
|
100
|
+
# (``RefreshToken.access_token`` is ``SET_NULL``), and that orphan can still mint new
|
|
101
|
+
# access tokens; revoking invalidates the whole token family consistently. Expired rows
|
|
102
|
+
# are pruned by the :ref:`cleartokens` management command.
|
|
103
|
+
return False
|
|
104
|
+
|
|
105
|
+
@admin.action(description="Revoke selected access tokens")
|
|
106
|
+
def revoke_tokens(self, request, queryset):
|
|
107
|
+
# ``revoke_access_token`` is the shared revoke path (also used by the ``/revoke/`` endpoint
|
|
108
|
+
# and ``AuthorizedTokenDeleteView``): it revokes the bound refresh token when present --
|
|
109
|
+
# preserving the tombstone ``REFRESH_TOKEN_REUSE_PROTECTION`` relies on -- otherwise
|
|
110
|
+
# revokes the access token directly.
|
|
111
|
+
revoked = 0
|
|
112
|
+
for access_token in queryset:
|
|
113
|
+
revoke_access_token(access_token)
|
|
114
|
+
revoked += 1
|
|
115
|
+
self.message_user(
|
|
116
|
+
request,
|
|
117
|
+
ngettext("Revoked %d access token.", "Revoked %d access tokens.", revoked) % revoked,
|
|
118
|
+
)
|
|
119
|
+
|
|
94
120
|
def get_exclude(self, request, obj=None):
|
|
95
121
|
# Hide the raw token on the change/view form (obj is set). Adding is disabled
|
|
96
122
|
# (see has_add_permission), so the add form is unreachable; guarding on obj keeps
|
|
@@ -164,11 +190,33 @@ class RefreshTokenAdmin(admin.ModelAdmin):
|
|
|
164
190
|
# Search by non-secret identifiers only; never by the token itself.
|
|
165
191
|
search_fields = ("application__client_id", "application__name") + USER_SEARCH_FIELDS
|
|
166
192
|
list_filter = ("application",)
|
|
193
|
+
actions = ("revoke_tokens",)
|
|
167
194
|
|
|
168
195
|
def has_add_permission(self, request):
|
|
169
196
|
# Refresh tokens are issued by the OAuth flows, not hand-created in the admin.
|
|
170
197
|
return False
|
|
171
198
|
|
|
199
|
+
def has_delete_permission(self, request, obj=None):
|
|
200
|
+
# Invalidate refresh tokens with the "Revoke selected refresh tokens" action, not a raw
|
|
201
|
+
# delete. ``RefreshToken.revoke()`` revokes the bound access token and keeps the refresh
|
|
202
|
+
# token as a revoked tombstone, which ``REFRESH_TOKEN_REUSE_PROTECTION`` needs to detect
|
|
203
|
+
# replay of a rotated token; a raw delete would discard that. Revoked/expired rows are
|
|
204
|
+
# pruned by the :ref:`cleartokens` management command.
|
|
205
|
+
return False
|
|
206
|
+
|
|
207
|
+
@admin.action(description="Revoke selected refresh tokens")
|
|
208
|
+
def revoke_tokens(self, request, queryset):
|
|
209
|
+
revoked = 0
|
|
210
|
+
for refresh_token in queryset:
|
|
211
|
+
# ``RefreshToken.revoke()`` revokes the bound access token and marks this token
|
|
212
|
+
# revoked; it is a no-op on an already-revoked token.
|
|
213
|
+
refresh_token.revoke()
|
|
214
|
+
revoked += 1
|
|
215
|
+
self.message_user(
|
|
216
|
+
request,
|
|
217
|
+
ngettext("Revoked %d refresh token.", "Revoked %d refresh tokens.", revoked) % revoked,
|
|
218
|
+
)
|
|
219
|
+
|
|
172
220
|
def get_exclude(self, request, obj=None):
|
|
173
221
|
# Hide the raw token on the change/view form. Adding is disabled (see
|
|
174
222
|
# has_add_permission), so the add form is unreachable; guarding on obj keeps this
|
|
@@ -178,7 +178,13 @@ def validate_bcp_configuration(app_configs, **kwargs):
|
|
|
178
178
|
return messages
|
|
179
179
|
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
# Registered under the ``models`` tag rather than ``database``: this check only asks the
|
|
182
|
+
# configured routers where the token models would be written, which is static analysis and
|
|
183
|
+
# never opens a connection. Django 6.1 stopped running ``database``-tagged checks unless a
|
|
184
|
+
# database alias is passed explicitly (``manage.py check --database default``), because
|
|
185
|
+
# those checks may do more than static analysis -- keeping this one under that tag would
|
|
186
|
+
# silently disable it for everyone running a plain ``manage.py check``.
|
|
187
|
+
@checks.register(checks.Tags.models)
|
|
182
188
|
def validate_token_configuration(app_configs, **kwargs):
|
|
183
189
|
databases = set(
|
|
184
190
|
router.db_for_write(apps.get_model(model))
|
|
@@ -199,3 +205,44 @@ def validate_token_configuration(app_configs, **kwargs):
|
|
|
199
205
|
return [checks.Error("The token models are expected to be stored in the same database.")]
|
|
200
206
|
|
|
201
207
|
return []
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
@checks.register(checks.Tags.models)
|
|
211
|
+
def validate_swapped_model_consistency(app_configs, **kwargs):
|
|
212
|
+
"""
|
|
213
|
+
Warn when the two circularly related token models are not swapped together.
|
|
214
|
+
|
|
215
|
+
``AccessToken.source_refresh_token`` points at ``REFRESH_TOKEN_MODEL`` and
|
|
216
|
+
``RefreshToken.access_token`` points back at ``ACCESS_TOKEN_MODEL``, so the two
|
|
217
|
+
models reference each other. Swapping only one of them -- e.g. pointing
|
|
218
|
+
``OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL`` at a custom model while leaving
|
|
219
|
+
``RefreshToken`` on the default ``oauth2_provider.RefreshToken`` -- produces a
|
|
220
|
+
circular foreign key that spans two apps. Django cannot order the initial
|
|
221
|
+
migration for such a graph, which surfaces as ``fields.E304``/``E305`` reverse
|
|
222
|
+
accessor clashes or "lazy reference ... isn't installed" migration errors.
|
|
223
|
+
|
|
224
|
+
The two models must therefore live in the same app. This is only a warning:
|
|
225
|
+
wiring the cross-app migration dependencies by hand is possible, but it is almost
|
|
226
|
+
always a mistake rather than an intention.
|
|
227
|
+
"""
|
|
228
|
+
access_app = oauth2_settings.ACCESS_TOKEN_MODEL.split(".", 1)[0]
|
|
229
|
+
refresh_app = oauth2_settings.REFRESH_TOKEN_MODEL.split(".", 1)[0]
|
|
230
|
+
if access_app != refresh_app:
|
|
231
|
+
return [
|
|
232
|
+
checks.Warning(
|
|
233
|
+
"The configured AccessToken model "
|
|
234
|
+
f"('{oauth2_settings.ACCESS_TOKEN_MODEL}') and RefreshToken model "
|
|
235
|
+
f"('{oauth2_settings.REFRESH_TOKEN_MODEL}') are defined in different apps, "
|
|
236
|
+
"but they reference each other with a circular foreign key.",
|
|
237
|
+
hint=(
|
|
238
|
+
"Swap the AccessToken and RefreshToken models into the same app -- e.g. "
|
|
239
|
+
"point OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL and "
|
|
240
|
+
"OAUTH2_PROVIDER_REFRESH_TOKEN_MODEL at models in one app. The IDToken "
|
|
241
|
+
"model is usually customized alongside them. See 'Extending the token "
|
|
242
|
+
"models' in the advanced topics documentation."
|
|
243
|
+
),
|
|
244
|
+
id="oauth2_provider.W011",
|
|
245
|
+
)
|
|
246
|
+
]
|
|
247
|
+
|
|
248
|
+
return []
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The `compat` module provides support for backwards compatibility with older
|
|
3
|
+
versions of Django, Python and oauthlib.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from oauthlib.oauth2.rfc8628.grant_types import DeviceCodeGrant
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
# Django 5.1 introduced LoginRequiredMiddleware, and login_not_required decorator
|
|
11
|
+
from django.contrib.auth.decorators import login_not_required
|
|
12
|
+
except ImportError:
|
|
13
|
+
|
|
14
|
+
def login_not_required(view_func):
|
|
15
|
+
return view_func
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# oauthlib 4.0.1 made the device code grant validate RFC 8628 requests itself: the
|
|
19
|
+
# device authorization request's scope (returning the resolved scope with the
|
|
20
|
+
# response) and, at the token request, the device code's status through the
|
|
21
|
+
# ``RequestValidator.validate_device_code`` hook, bound to the authenticated client.
|
|
22
|
+
# Older oauthlib left both to the caller.
|
|
23
|
+
OAUTHLIB_VALIDATES_DEVICE_CODE = hasattr(DeviceCodeGrant, "validate_device_code")
|
|
24
|
+
|
|
25
|
+
__all__ = ["OAUTHLIB_VALIDATES_DEVICE_CODE", "login_not_required"]
|
|
@@ -45,11 +45,17 @@ class TokenHasScope(BasePermission):
|
|
|
45
45
|
|
|
46
46
|
return False
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
# request.auth is not an OAuth2 access token (it has no `scope` attribute),
|
|
49
|
+
# e.g. it came from a different authentication class in a composed
|
|
50
|
+
# permission. Deny the request instead of raising, so this permission can be
|
|
51
|
+
# combined (AND/OR) with others without turning a non-OAuth2 request into an
|
|
52
|
+
# uncaught AssertionError / HTTP 500. See #1169.
|
|
53
|
+
log.warning(
|
|
54
|
+
"TokenHasScope requires the "
|
|
55
|
+
"`oauth2_provider.contrib.rest_framework.OAuth2Authentication` authentication "
|
|
51
56
|
"class to be used."
|
|
52
57
|
)
|
|
58
|
+
return False
|
|
53
59
|
|
|
54
60
|
def get_scopes(self, request, view):
|
|
55
61
|
try:
|
|
@@ -167,11 +173,14 @@ class TokenMatchesOASRequirements(BasePermission):
|
|
|
167
173
|
log.warning("no scope alternates defined for method {0}".format(m))
|
|
168
174
|
return False
|
|
169
175
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
# See TokenHasScope above and #1169: deny rather than raise when the token
|
|
177
|
+
# is not an OAuth2 access token, so this permission composes cleanly.
|
|
178
|
+
log.warning(
|
|
179
|
+
"TokenMatchesOASRequirements requires the "
|
|
180
|
+
"`oauth2_provider.contrib.rest_framework.OAuth2Authentication` authentication "
|
|
173
181
|
"class to be used."
|
|
174
182
|
)
|
|
183
|
+
return False
|
|
175
184
|
|
|
176
185
|
def get_required_alternate_scopes(self, request, view):
|
|
177
186
|
try:
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
from typing import Any, Optional
|
|
2
|
+
|
|
1
3
|
from django import forms
|
|
2
4
|
from django.contrib.auth.hashers import identify_hasher
|
|
5
|
+
from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
|
|
3
6
|
from django.utils.translation import gettext_lazy as _
|
|
4
7
|
|
|
5
8
|
|
|
@@ -134,6 +137,24 @@ class ApplicationForm(forms.ModelForm):
|
|
|
134
137
|
}
|
|
135
138
|
)
|
|
136
139
|
|
|
140
|
+
def add_error(self, field: Optional[str], error: Any) -> None:
|
|
141
|
+
"""Fold model errors naming a field this form omits into non-field errors.
|
|
142
|
+
|
|
143
|
+
``Application.clean()`` keys its errors by field so a ModelForm renders each one
|
|
144
|
+
next to the offending input. Django hands those to ``add_error(None, error_dict)``
|
|
145
|
+
and raises ``ValueError`` if a key is not a field of the form -- which a subclass
|
|
146
|
+
with a narrower ``Meta.fields`` can easily trigger (e.g. omitting ``redirect_uris``
|
|
147
|
+
while keeping ``authorization_grant_type``). Re-key the unknown ones so such a form
|
|
148
|
+
still shows the message, as a non-field error, instead of raising.
|
|
149
|
+
"""
|
|
150
|
+
if field is None and hasattr(error, "error_dict"):
|
|
151
|
+
rekeyed = {}
|
|
152
|
+
for error_field, messages in error.error_dict.items():
|
|
153
|
+
key = error_field if error_field in self.fields else NON_FIELD_ERRORS
|
|
154
|
+
rekeyed.setdefault(key, []).extend(messages)
|
|
155
|
+
error = ValidationError(rekeyed)
|
|
156
|
+
super().add_error(field, error)
|
|
157
|
+
|
|
137
158
|
class Media:
|
|
138
159
|
js = ("oauth2_provider/js/application_form.js",)
|
|
139
160
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from django.core.management.base import BaseCommand
|
|
2
|
+
|
|
3
|
+
from ...models import clear_expired, refresh_token_expire_timedelta
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Command(BaseCommand):
|
|
7
|
+
help = "Can be run as a cronjob or directly to clean out expired tokens"
|
|
8
|
+
|
|
9
|
+
def handle(self, *args, **options):
|
|
10
|
+
if refresh_token_expire_timedelta() is None:
|
|
11
|
+
self.stderr.write(
|
|
12
|
+
self.style.WARNING(
|
|
13
|
+
"REFRESH_TOKEN_EXPIRE_SECONDS is not set (or is 0), so refresh tokens never "
|
|
14
|
+
"age-expire. cleartokens will only remove revoked and orphaned refresh tokens; "
|
|
15
|
+
"expired access and ID tokens that are still bound to a refresh token are kept "
|
|
16
|
+
"as long as that refresh token lives. Set REFRESH_TOKEN_EXPIRE_SECONDS to enable "
|
|
17
|
+
"expiry-based cleanup."
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
clear_expired()
|