Skip to content

Commit 40df294

Browse files
authored
Merge branch 'master' into multiple_rsa_keys
2 parents a832e56 + 59ab199 commit 40df294

File tree

9 files changed

+231
-30
lines changed

9 files changed

+231
-30
lines changed

AUTHORS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Alan Crosswell
1212
Aleksander Vaskevich
1313
Alessandro De Angelis
1414
Allisson Azevedo
15+
Andrew Chen Wang
1516
Anvesh Agarwal
1617
Aristóbulo Meneses
1718
Aryan Iyappan
@@ -30,14 +31,17 @@ Emanuele Palazzetti
3031
Federico Dolce
3132
Frederico Vieira
3233
Hasan Ramezani
34+
Hossein Shakiba
3335
Hiroki Kiyohara
3436
Jens Timmerman
3537
Jerome Leclanche
3638
Jim Graham
3739
Jonas Nygaard Pedersen
3840
Jonathan Steffan
41+
Jozef Knaperek
3942
Jun Zhou
4043
Kristian Rune Larsen
44+
Michael Howitz
4145
Paul Dekkers
4246
Paul Oswald
4347
Pavel Tvrdík

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
## [unreleased]
1818
* Remove support for Django 3.0
1919
* Add support for Django 3.2
20+
* #989 Change any HttpResponse to JsonResponse if possible
2021

2122
### Added
2223
* #712, #636, #808. Calls to `django.contrib.auth.authenticate()` now pass a `request`

docs/getting_started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Export the credential as an environment variable
358358
359359
export CREDENTIAL=YXhYU1NCVnV2T3lHVnpoNFB1cnZLYXE1TUhYTW03RnRySGdETWk0dToxZnV2NVdWZlI3QTVCbEYwbzE1NUg3czViTGdYbHdXTGhpM1k3cGRKOWFKdUNkbDBYVjVDeGdkMHRyaTduU3pDODBxeXJvdmg4cUZYRkhnRkFBYzBsZFBObjVaWUxhbnhTbTFTSTFyeGxScldVUDU5MXdwSERHYTNwU3BCNmRDWg==
360360
361-
To start the Client Credential flow you call ``/token/`` endpoint direct::
361+
To start the Client Credential flow you call ``/token/`` endpoint directly::
362362

363363
curl -X POST -H "Authorization: Basic ${CREDENTIAL}" -H "Cache-Control: no-cache" -H "Content-Type: application/x-www-form-urlencoded" "http://127.0.0.1:8000/o/token/" -d "grant_type=client_credentials"
364364

docs/settings.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ REFRESH_TOKEN_EXPIRE_SECONDS
147147
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148148
The number of seconds before a refresh token gets removed from the database by
149149
the ``cleartokens`` management command. Check :ref:`cleartokens` management command for further info.
150+
Can be an ``Int`` or ``datetime.timedelta``.
151+
150152
NOTE: This value is completely ignored when validating refresh tokens.
151153
If you don't change the validator code and don't run cleartokens all refresh
152154
tokens will last until revoked or the end of time. You should change this.

docs/tutorial/tutorial_01.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Start Your App
99
--------------
1010
During this tutorial you will make an XHR POST from a Heroku deployed app to your localhost instance.
1111
Since the domain that will originate the request (the app on Heroku) is different from the destination domain (your local instance),
12-
you will need to install the `django-cors-middleware <https://github.com/zestedesavoir/django-cors-middleware>`_ app.
12+
you will need to install the `django-cors-headers <https://github.com/adamchainz/django-cors-headers>`_ app.
1313
These "cross-domain" requests are by default forbidden by web browsers unless you use `CORS <http://en.wikipedia.org/wiki/Cross-origin_resource_sharing>`_.
1414

15-
Create a virtualenv and install `django-oauth-toolkit` and `django-cors-middleware`:
15+
Create a virtualenv and install `django-oauth-toolkit` and `django-cors-headers`:
1616

1717
::
1818

19-
pip install django-oauth-toolkit django-cors-middleware
19+
pip install django-oauth-toolkit django-cors-headers
2020

2121
Start a Django project, add `oauth2_provider` and `corsheaders` to the installed apps, and enable admin:
2222

@@ -33,6 +33,8 @@ Include the Django OAuth Toolkit urls in your `urls.py`, choosing the urlspace y
3333

3434
.. code-block:: python
3535
36+
from django.urls import path, include
37+
3638
urlpatterns = [
3739
path("admin", admin.site.urls),
3840
path("o/", include('oauth2_provider.urls', namespace='oauth2_provider')),

oauth2_provider/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ApplicationAdmin(admin.ModelAdmin):
2626

2727
class AccessTokenAdmin(admin.ModelAdmin):
2828
list_display = ("token", "user", "application", "expires")
29+
list_select_related = ("application", "user")
2930
raw_id_fields = ("user", "source_refresh_token")
3031

3132

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3+
# This file is distributed under the same license as the PACKAGE package.
4+
# FIRST AUTHOR <[email protected]>, YEAR.
5+
#
6+
#, fuzzy
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: PACKAGE VERSION\n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"POT-Creation-Date: 2021-05-01 15:33+0430\n"
12+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13+
"Last-Translator: HOSSEIN SHAKIBA <[email protected]>\n"
14+
"Language-Team: LANGUAGE <[email protected]>\n"
15+
"Language: \n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
20+
21+
#: models.py:49
22+
msgid "Confidential"
23+
msgstr "محرمانه"
24+
25+
#: models.py:50
26+
msgid "Public"
27+
msgstr "عمومی"
28+
29+
#: models.py:59
30+
msgid "Authorization code"
31+
msgstr "کد مجوز"
32+
33+
#: models.py:60
34+
msgid "Implicit"
35+
msgstr "ضمنی"
36+
37+
#: models.py:61
38+
msgid "Resource owner password-based"
39+
msgstr "صاحب منبع مبتنی بر رمز عبور"
40+
41+
#: models.py:62
42+
msgid "Client credentials"
43+
msgstr "اعتبار مخاطب"
44+
45+
#: models.py:63
46+
msgid "OpenID connect hybrid"
47+
msgstr "اتصال ترکیبی OpenID"
48+
49+
#: models.py:70
50+
msgid "No OIDC support"
51+
msgstr "OIDC پشتیبانی وجود ندارد از"
52+
53+
#: models.py:71
54+
msgid "RSA with SHA-2 256"
55+
msgstr "SHA-2 256 با RSA"
56+
57+
#: models.py:72
58+
msgid "HMAC with SHA-2 256"
59+
msgstr "SHA-2 256 با HMAC"
60+
61+
#: models.py:87
62+
msgid "Allowed URIs list, space separated"
63+
msgstr "مجاز، با فاصله از هم جدا شده‌اند URIs فهرست"
64+
65+
#: models.py:152
66+
#, python-brace-format
67+
msgid "Unauthorized redirect scheme: {scheme}"
68+
msgstr "{scheme} :طرح تغییر مسیر غیرمجاز"
69+
70+
#: models.py:156
71+
#, python-brace-format
72+
msgid "redirect_uris cannot be empty with grant_type {grant_type}"
73+
msgstr "{grant_type} خالی باشد grant_type نمی تواند با redirect_uris "
74+
75+
#: models.py:162
76+
msgid "You must set OIDC_RSA_PRIVATE_KEY to use RSA algorithm"
77+
msgstr "را تنظیم کنید OIDC_RSA_PRIVATE_KEY باید RSA برای استفاده از الگوریتم"
78+
79+
#: models.py:171
80+
msgid "You cannot use HS256 with public grants or clients"
81+
msgstr ""
82+
83+
#: oauth2_validators.py:181
84+
msgid "The access token is invalid."
85+
msgstr "توکن دسترسی نامعتبر است"
86+
87+
#: oauth2_validators.py:188
88+
msgid "The access token has expired."
89+
msgstr "توکن دسترسی منقضی شده است"
90+
91+
#: oauth2_validators.py:195
92+
msgid "The access token is valid but does not have enough scope."
93+
msgstr "توکن دسترسی معتبر است اما دامنه کافی ندارد"
94+
95+
#: templates/oauth2_provider/application_confirm_delete.html:6
96+
msgid "Are you sure to delete the application"
97+
msgstr "آیا مطمئن هستید که برنامه را حذف می کنید"
98+
99+
#: templates/oauth2_provider/application_confirm_delete.html:12
100+
#: templates/oauth2_provider/authorize.html:29
101+
msgid "Cancel"
102+
msgstr "لغو"
103+
104+
#: templates/oauth2_provider/application_confirm_delete.html:13
105+
#: templates/oauth2_provider/application_detail.html:38
106+
#: templates/oauth2_provider/authorized-token-delete.html:7
107+
msgid "Delete"
108+
msgstr "حذف"
109+
110+
#: templates/oauth2_provider/application_detail.html:10
111+
msgid "Client id"
112+
msgstr "شناسه(آیدی) کاربر"
113+
114+
#: templates/oauth2_provider/application_detail.html:15
115+
msgid "Client secret"
116+
msgstr "راز کاربر"
117+
118+
#: templates/oauth2_provider/application_detail.html:20
119+
msgid "Client type"
120+
msgstr "نوع کاربر"
121+
122+
#: templates/oauth2_provider/application_detail.html:25
123+
msgid "Authorization Grant Type"
124+
msgstr "نوع اعطای مجوز"
125+
126+
#: templates/oauth2_provider/application_detail.html:30
127+
msgid "Redirect Uris"
128+
msgstr "تغییر مسیر URIs"
129+
130+
#: templates/oauth2_provider/application_detail.html:36
131+
#: templates/oauth2_provider/application_form.html:35
132+
msgid "Go Back"
133+
msgstr "بازگشت"
134+
135+
#: templates/oauth2_provider/application_detail.html:37
136+
msgid "Edit"
137+
msgstr "ویرایش"
138+
139+
#: templates/oauth2_provider/application_form.html:9
140+
msgid "Edit application"
141+
msgstr "ویرایش برنامه"
142+
143+
#: templates/oauth2_provider/application_form.html:37
144+
msgid "Save"
145+
msgstr "ذخیره"
146+
147+
#: templates/oauth2_provider/application_list.html:6
148+
msgid "Your applications"
149+
msgstr "برنامه شما"
150+
151+
#: templates/oauth2_provider/application_list.html:14
152+
msgid "New Application"
153+
msgstr "برنامه جدید"
154+
155+
#: templates/oauth2_provider/application_list.html:17
156+
msgid "No applications defined"
157+
msgstr "هیچ برنامه ای تعریف نشده است"
158+
159+
#: templates/oauth2_provider/application_list.html:17
160+
msgid "Click here"
161+
msgstr "اینجا کلیک کنید"
162+
163+
#: templates/oauth2_provider/application_list.html:17
164+
msgid "if you want to register a new one"
165+
msgstr "اگر می خواهید مورد جدیدی ثبت کنید"
166+
167+
#: templates/oauth2_provider/application_registration_form.html:5
168+
msgid "Register a new application"
169+
msgstr "ثبت یک برنامه جدید"
170+
171+
#: templates/oauth2_provider/authorize.html:8
172+
#: templates/oauth2_provider/authorize.html:30
173+
msgid "Authorize"
174+
msgstr "اجازه دادن"
175+
176+
#: templates/oauth2_provider/authorize.html:17
177+
msgid "Application requires the following permissions"
178+
msgstr "برنامه به مجوزهای زیر نیاز دارد"
179+
180+
#: templates/oauth2_provider/authorized-oob.html:12
181+
msgid "Success"
182+
msgstr "موفقیت"
183+
184+
#: templates/oauth2_provider/authorized-oob.html:14
185+
msgid "Please return to your application and enter this code:"
186+
msgstr "لطفاً به برنامه خود برگردید و این کد را وارد کنید:"
187+
188+
#: templates/oauth2_provider/authorized-token-delete.html:6
189+
msgid "Are you sure you want to delete this token?"
190+
msgstr "آیا مطمئن هستید که می خواهید این توکن را حذف کنید؟"
191+
192+
#: templates/oauth2_provider/authorized-tokens.html:6
193+
msgid "Tokens"
194+
msgstr "توکن‌ها"
195+
196+
#: templates/oauth2_provider/authorized-tokens.html:11
197+
msgid "revoke"
198+
msgstr "باطل کردن"
199+
200+
#: templates/oauth2_provider/authorized-tokens.html:19
201+
msgid "There are no authorized tokens yet."
202+
msgstr "هنوز هیچ توکن مجازی وجود ندارد."

oauth2_provider/models.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def default_redirect_uri(self):
114114
return self.redirect_uris.split().pop(0)
115115

116116
assert False, (
117-
"If you are using implicit, authorization_code"
117+
"If you are using implicit, authorization_code "
118118
"or all-in-one grant_type, you must define "
119119
"redirect_uris field in your Application model"
120120
)
@@ -563,56 +563,56 @@ class Meta(AbstractIDToken.Meta):
563563

564564

565565
def get_application_model():
566-
""" Return the Application model that is active in this project. """
566+
"""Return the Application model that is active in this project."""
567567
return apps.get_model(oauth2_settings.APPLICATION_MODEL)
568568

569569

570570
def get_grant_model():
571-
""" Return the Grant model that is active in this project. """
571+
"""Return the Grant model that is active in this project."""
572572
return apps.get_model(oauth2_settings.GRANT_MODEL)
573573

574574

575575
def get_access_token_model():
576-
""" Return the AccessToken model that is active in this project. """
576+
"""Return the AccessToken model that is active in this project."""
577577
return apps.get_model(oauth2_settings.ACCESS_TOKEN_MODEL)
578578

579579

580580
def get_id_token_model():
581-
""" Return the AccessToken model that is active in this project. """
581+
"""Return the AccessToken model that is active in this project."""
582582
return apps.get_model(oauth2_settings.ID_TOKEN_MODEL)
583583

584584

585585
def get_refresh_token_model():
586-
""" Return the RefreshToken model that is active in this project. """
586+
"""Return the RefreshToken model that is active in this project."""
587587
return apps.get_model(oauth2_settings.REFRESH_TOKEN_MODEL)
588588

589589

590590
def get_application_admin_class():
591-
""" Return the Application admin class that is active in this project. """
591+
"""Return the Application admin class that is active in this project."""
592592
application_admin_class = oauth2_settings.APPLICATION_ADMIN_CLASS
593593
return application_admin_class
594594

595595

596596
def get_access_token_admin_class():
597-
""" Return the AccessToken admin class that is active in this project. """
597+
"""Return the AccessToken admin class that is active in this project."""
598598
access_token_admin_class = oauth2_settings.ACCESS_TOKEN_ADMIN_CLASS
599599
return access_token_admin_class
600600

601601

602602
def get_grant_admin_class():
603-
""" Return the Grant admin class that is active in this project. """
603+
"""Return the Grant admin class that is active in this project."""
604604
grant_admin_class = oauth2_settings.GRANT_ADMIN_CLASS
605605
return grant_admin_class
606606

607607

608608
def get_id_token_admin_class():
609-
""" Return the IDToken admin class that is active in this project. """
609+
"""Return the IDToken admin class that is active in this project."""
610610
id_token_admin_class = oauth2_settings.ID_TOKEN_ADMIN_CLASS
611611
return id_token_admin_class
612612

613613

614614
def get_refresh_token_admin_class():
615-
""" Return the RefreshToken admin class that is active in this project. """
615+
"""Return the RefreshToken admin class that is active in this project."""
616616
refresh_token_admin_class = oauth2_settings.REFRESH_TOKEN_ADMIN_CLASS
617617
return refresh_token_admin_class
618618

0 commit comments

Comments
 (0)