From 71ca491fc5c1fcff31a1c40ad90d53456f17c3da Mon Sep 17 00:00:00 2001 From: Armenak Baburyan <1723973+armenak-baburyan@users.noreply.github.com> Date: Mon, 6 Jun 2022 00:12:55 +0400 Subject: [PATCH 1/7] Allow optional installation of the 'cryptography' package (#543) --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 5687b6604..b99a707c7 100755 --- a/setup.py +++ b/setup.py @@ -30,6 +30,9 @@ "python-jose": [ "python-jose==3.3.0", ], + "crypto": [ + "cryptography>=3.3.1", + ], } extras_require["dev"] = ( From e55d0d0458dd3e042fd634ef731d487f88716d5a Mon Sep 17 00:00:00 2001 From: Armenak Baburyan <1723973+armenak-baburyan@users.noreply.github.com> Date: Mon, 6 Jun 2022 00:31:02 +0400 Subject: [PATCH 2/7] Update docs (#543) --- docs/getting_started.rst | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 8e961d34d..1a61a78d9 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -21,6 +21,26 @@ Simple JWT can be installed with pip:: pip install djangorestframework-simplejwt + +Cryptographic Dependencies (Optional) +------------------------------------- + +If you are planning on encoding or decoding tokens using certain digital +signature algorithms (like RSA or ECDSA), you will need to install the +cryptography_ library. This can be installed explicitly, or as a required +extra in the ``Simple JWT`` requirement: + +.. code-block:: console + + $ pip install djangorestframework-simplejwt[crypto] + +The ``djangorestframework-simplejwt[crypto]`` format is recommended in requirements +files in projects using ``Simple JWT``, as a separate ``cryptography`` requirement +line may later be mistaken for an unused requirement and removed. + + +.. _`cryptography`: https://cryptography.io + Then, your django project must be configured to use the library. In ``settings.py``, add ``rest_framework_simplejwt.authentication.JWTAuthentication`` to the list of @@ -59,16 +79,16 @@ allow API users to verify HMAC-signed tokens without having access to your signing key: .. code-block:: python - + from rest_framework_simplejwt.views import TokenVerifyView - + urlpatterns = [ ... path('api/token/verify/', TokenVerifyView.as_view(), name='token_verify'), ... ] -If you wish to use localizations/translations, simply add +If you wish to use localizations/translations, simply add ``rest_framework_simplejwt`` to ``INSTALLED_APPS``. .. code-block:: python From d59840d56be37f778b1724f6d40e455726804f15 Mon Sep 17 00:00:00 2001 From: Armenak Baburyan <1723973+armenak-baburyan@users.noreply.github.com> Date: Mon, 6 Jun 2022 00:44:38 +0400 Subject: [PATCH 3/7] Update docs (#543) --- docs/getting_started.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 1a61a78d9..9c8f43899 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -28,7 +28,7 @@ Cryptographic Dependencies (Optional) If you are planning on encoding or decoding tokens using certain digital signature algorithms (like RSA or ECDSA), you will need to install the cryptography_ library. This can be installed explicitly, or as a required -extra in the ``Simple JWT`` requirement: +extra in the ``djangorestframework-simplejwt`` requirement: .. code-block:: console @@ -41,6 +41,9 @@ line may later be mistaken for an unused requirement and removed. .. _`cryptography`: https://cryptography.io +Project Configuration +--------------------- + Then, your django project must be configured to use the library. In ``settings.py``, add ``rest_framework_simplejwt.authentication.JWTAuthentication`` to the list of From 6ae6b9a21fe3bee8ee88b02fb43403aa2786d978 Mon Sep 17 00:00:00 2001 From: Armenak Baburyan <1723973+armenak-baburyan@users.noreply.github.com> Date: Mon, 6 Jun 2022 01:04:14 +0400 Subject: [PATCH 4/7] Update docs/getting_started.rst Co-authored-by: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> --- docs/getting_started.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 9c8f43899..4097cc1da 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -26,7 +26,7 @@ Cryptographic Dependencies (Optional) ------------------------------------- If you are planning on encoding or decoding tokens using certain digital -signature algorithms (like RSA or ECDSA), you will need to install the +signature algorithms (i.e. RSA and ECDSA; visit PyJWT for other algorithms), you will need to install the cryptography_ library. This can be installed explicitly, or as a required extra in the ``djangorestframework-simplejwt`` requirement: From f1f3320f6501037af1e3ae24016e261a7787c998 Mon Sep 17 00:00:00 2001 From: Armenak Baburyan <1723973+armenak-baburyan@users.noreply.github.com> Date: Mon, 6 Jun 2022 01:06:29 +0400 Subject: [PATCH 5/7] fix for code-block (#543) --- docs/getting_started.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 4097cc1da..6f63d4fbd 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -32,7 +32,7 @@ extra in the ``djangorestframework-simplejwt`` requirement: .. code-block:: console - $ pip install djangorestframework-simplejwt[crypto] + pip install djangorestframework-simplejwt[crypto] The ``djangorestframework-simplejwt[crypto]`` format is recommended in requirements files in projects using ``Simple JWT``, as a separate ``cryptography`` requirement From 5f1db1c22599cdec9736c0be62756d7c85c5cc00 Mon Sep 17 00:00:00 2001 From: Armenak Baburyan <1723973+armenak-baburyan@users.noreply.github.com> Date: Mon, 6 Jun 2022 01:08:22 +0400 Subject: [PATCH 6/7] another fix for code-block (#543) --- docs/getting_started.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 6f63d4fbd..1793935a5 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -17,7 +17,9 @@ possible. Installation ------------ -Simple JWT can be installed with pip:: +Simple JWT can be installed with pip: + +.. code-block:: console pip install djangorestframework-simplejwt From 8e159e803988176cce3e3e98a7ab64d5d51df0fe Mon Sep 17 00:00:00 2001 From: Armenak Baburyan <1723973+armenak-baburyan@users.noreply.github.com> Date: Mon, 6 Jun 2022 01:09:54 +0400 Subject: [PATCH 7/7] fix: removed extra line (#543) --- docs/getting_started.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 1793935a5..c07382414 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -40,7 +40,6 @@ The ``djangorestframework-simplejwt[crypto]`` format is recommended in requireme files in projects using ``Simple JWT``, as a separate ``cryptography`` requirement line may later be mistaken for an unused requirement and removed. - .. _`cryptography`: https://cryptography.io Project Configuration