Skip to content

Commit a96c525

Browse files
eadwinCodePijulibertonhaAndrew-Chen-Wangvainu-arto
authored
October-30-2022:Jazz master branch merge (#15)
* Fix ES locale translation error (jazzband#499) * chore: test on Django 4.0 (jazzband#495) * chore: test on Django 4.0 * Remove Django 3.1 support from trove * Remove Django 3.1 from tox * Remove 3.1 reference in tox.ini Co-authored-by: Andrew Chen Wang <[email protected]> * Stop deleting blacklist on user delete (jazzband#516) * OutstandingToken user on_delete should be null * Add test to verify that deleting a User doesn't remove tokens from the blacklist This is a rather unexpected default behavior. Deleting a User means that their blacklisted tokens become live again. * Add migration for cascading User deletion to SET_NULL instead of DELETE * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Andrew Chen Wang <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [pre-commit.ci] pre-commit autoupdate (jazzband#498) updates: - [github.com/pre-commit/pre-commit-hooks: v4.0.1 → v4.1.0](pre-commit/pre-commit-hooks@v4.0.1...v4.1.0) - [github.com/asottile/yesqa: v1.2.3 → v1.3.0](asottile/yesqa@v1.2.3...v1.3.0) - [github.com/pycqa/isort: 5.9.3 → 5.10.1](PyCQA/isort@5.9.3...5.10.1) - [github.com/psf/black: 21.9b0 → 21.12b0](psf/black@21.9b0...21.12b0) - [github.com/pre-commit/pre-commit-hooks: v4.0.1 → v4.1.0](pre-commit/pre-commit-hooks@v4.0.1...v4.1.0) - [github.com/asottile/pyupgrade: v2.28.0 → v2.31.0](asottile/pyupgrade@v2.28.0...v2.31.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Enable ECDSA algorithms supported by PyJWT (jazzband#520) * Parameterize some tests to reduce duplication and make it easy to add more algorithms This way new algorithms can be added to the basic test set simply by adding their backends to TestTokenBackend.backends. * Enable ECDSA algorithms supported by PyJWT Enable the algorithms and add basic tests for them. Also convert the ALLOWED_ALGORITHMS constant to a set for a minor style cleanup. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Simplify using custom token classes in serializers (jazzband#517) For most cases this could be done by overriding get_token, which is simple enough. The exception was TokenRefreshSerializer.validate where the entire method needed to be copy-pasted to allow using a custom replacement for RefreshToken. The other cases are changed the same way mainly for consistency. * [pre-commit.ci] pre-commit autoupdate (jazzband#524) updates: - [github.com/psf/black: 21.12b0 → 22.1.0](psf/black@21.12b0...22.1.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Make the token serializer configurable (jazzband#521) * Update translation files (jazzband#526) * Add default __getattr__ behavior to models.TokenUser (jazzband#528) * Add default __getattr__ behavior to models.TokenUser to allow getting custom claims defined in serializers * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Allow overriding access token class (jazzband#529) * Maintain compatibility with serializer_class overrides (jazzband#530) * Consider leeway when checking expiry (jazzband#458) * Add locale checker to CI (jazzband#456) * Add locale checker to CI * Just pip install Django * Add gettext package to OS * Add sudo to apt-get * Use @2ykwang 's updated script * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Only update on push to master * To avoid pain points of PRs and histories being split * Trying to use Andrew's username for pushing to see if that works * Use separate workflow file Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Update CHANGELOG.md for v5.1.0 (jazzband#527) * Update CHANGELOG.md for v5.0.1 * Update CHANGELOG.md * Remove looking for maintainers in README since Jazzband Co-authored-by: Andrew Chen Wang <[email protected]> * Fix i18n CI (jazzband#538) * Open PR on i18n (jazzband#539) * fix small typo (jazzband#540) * Setup initial PyJWT 1.7.1 support (jazzband#536) * Fix release locale checker (jazzband#541) * Update locale files (jazzband#542) * [pre-commit.ci] pre-commit autoupdate (jazzband#545) updates: - [github.com/asottile/pyupgrade: v2.31.0 → v2.31.1](asottile/pyupgrade@v2.31.0...v2.31.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Remove the JWTTokenUserAuthentication from the Experimental Features jazzband#546 (jazzband#547) * Change from git protocol to https protocol (jazzband#555) * [pre-commit.ci] pre-commit autoupdate (jazzband#551) updates: - [github.com/psf/black: 22.1.0 → 22.3.0](psf/black@22.1.0...22.3.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Fix leeway type error (jazzband#554) * Fix lewway type error * Add test case * Update Korean translation * Add type hints * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix translation revert POT-Creation-Date * update translation Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [pre-commit.ci] pre-commit autoupdate (jazzband#557) * Add info on TokenBlacklistView to the docs (jazzband#558) * chore(ci): add informational Codecov status checks (jazzband#559) * Update JWTStatelessUserAuthentication docs (jazzband#561) * Allow none jti claim token type claim (jazzband#567) * Allow customizing token JSON encoding (jazzband#568) * Allow specifying custom JSONEncoder for TokenBackend * Make TokenBackend JSONEncoder configurable * [pre-commit.ci] pre-commit autoupdate (jazzband#571) updates: - [github.com/asottile/pyupgrade: v2.32.0 → v2.32.1](asottile/pyupgrade@v2.32.0...v2.32.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Update CHANGELOG to 5.2.0 (jazzband#573) * Locale update (jazzband#574) * update & correct supported versions in docs (jazzband#576) * update & correct supported versions in docs * Add DRF supported version Co-authored-by: Andrew Chen Wang <[email protected]> * Add Swedish translations (jazzband#579) * Fixed issue jazzband#543 (jazzband#586) * Allow optional installation of the 'cryptography' package (jazzband#543) * Update docs (jazzband#543) * Update docs (jazzband#543) * Update docs/getting_started.rst Co-authored-by: Andrew Chen Wang <[email protected]> * fix for code-block (jazzband#543) * another fix for code-block (jazzband#543) * fix: removed extra line (jazzband#543) Co-authored-by: Andrew Chen Wang <[email protected]> * [pre-commit.ci] pre-commit autoupdate (jazzband#587) updates: - [github.com/pre-commit/pre-commit-hooks: v4.2.0 → v4.3.0](pre-commit/pre-commit-hooks@v4.2.0...v4.3.0) - [github.com/pre-commit/pre-commit-hooks: v4.2.0 → v4.3.0](pre-commit/pre-commit-hooks@v4.2.0...v4.3.0) - [github.com/asottile/pyupgrade: v2.32.1 → v2.34.0](asottile/pyupgrade@v2.32.1...v2.34.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [pre-commit.ci] pre-commit autoupdate (jazzband#589) updates: - [github.com/psf/black: 22.3.0 → 22.6.0](psf/black@22.3.0...22.6.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [pre-commit.ci] pre-commit autoupdate (jazzband#590) * [pre-commit.ci] pre-commit autoupdate (jazzband#594) updates: - [github.com/asottile/pyupgrade: v2.37.1 → v2.37.2](asottile/pyupgrade@v2.37.1...v2.37.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [pre-commit.ci] pre-commit autoupdate (jazzband#597) updates: - [github.com/asottile/pyupgrade: v2.37.2 → v2.37.3](asottile/pyupgrade@v2.37.2...v2.37.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [pre-commit.ci] pre-commit autoupdate (jazzband#601) updates: - [github.com/asottile/yesqa: v1.3.0 → v1.4.0](asottile/yesqa@v1.3.0...v1.4.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Fix uncaught exception with JWK (jazzband#600) * Fix uncaught exception with JWK * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Allow tests to run on older JWT versions Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Test on Django 4.1 (jazzband#604) * [pre-commit.ci] pre-commit autoupdate (jazzband#609) * Add v5.2.1 changes (jazzband#611) * use non-deprecated UTC timezone (jazzband#606) RemovedInDjango50Warning * Added Romanian translations (jazzband#591) * Added Romanian translations * Changed some translations according to the grammatical rules of the Romanian language * Changed some translations according to the advices of: https://github.com/marcellefter https://github.com/uoxiu Co-authored-by: Daniel Cuznetov <[email protected]> * allow verification skipping (jazzband#605) * allow verify skip verification if VERIFYING_KEY is not set * Update settings.py * Update authentication.py * Update settings.py * Update authentication.py * [pre-commit.ci] pre-commit autoupdate (jazzband#619) * [pre-commit.ci] pre-commit autoupdate (jazzband#620) * Update locale files (jazzband#624) * Revert 605 (jazzband#629) * [pre-commit.ci] pre-commit autoupdate (jazzband#630) * [Docs] Fix typo in blacklist_app.rst (jazzband#593) * Fix typo in blacklist_app.rst `TokenBlackListView` -> `TokenBlacklistView` * Append CHANGELOG Co-authored-by: Andrew-Chen-Wang <[email protected]> Co-authored-by: Marc Salat <[email protected]> Co-authored-by: Christofer Bertonha <[email protected]> Co-authored-by: Andrew Chen Wang <[email protected]> Co-authored-by: vainu-arto <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: yeongkwang <[email protected]> Co-authored-by: Oscar Y Chen <[email protected]> Co-authored-by: totycro <[email protected]> Co-authored-by: Byron Motoche <[email protected]> Co-authored-by: Vladimir <[email protected]> Co-authored-by: Tom Hu <[email protected]> Co-authored-by: Dennis Dinwiddie <[email protected]> Co-authored-by: abdurrahman <[email protected]> Co-authored-by: Pasindu Prabhashitha <[email protected]> Co-authored-by: Armenak Baburyan <[email protected]> Co-authored-by: Jeremy Mayeres <[email protected]> Co-authored-by: Benedikt S. Vogler <[email protected]> Co-authored-by: Daniel Cuzneţov <[email protected]> Co-authored-by: Daniel Cuznetov <[email protected]> Co-authored-by: Domenico <[email protected]> Co-authored-by: Boseong Choi <[email protected]> Co-authored-by: Andrew-Chen-Wang <[email protected]>
1 parent bfcb427 commit a96c525

File tree

28 files changed

+452
-271
lines changed

28 files changed

+452
-271
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
## Unreleased
22

3+
## Version 5.2.2
4+
5+
Major security release
6+
7+
* Revert #605 in https://github.com/jazzband/djangorestframework-simplejwt/pull/629
8+
* Fix typo in blacklist_app.rst by @cbscsm in https://github.com/jazzband/djangorestframework-simplejwt/pull/593
9+
10+
## Version 5.2.1
11+
12+
* Add Swedish translations by @PasinduPrabhashitha in https://github.com/jazzband/djangorestframework-simplejwt/pull/579
13+
* Fixed issue #543 by @armenak-baburyan in https://github.com/jazzband/djangorestframework-simplejwt/pull/586
14+
* Fix uncaught exception with JWK by @jerr0328 in https://github.com/jazzband/djangorestframework-simplejwt/pull/600
15+
* Test on Django 4.1 by @2ykwang in https://github.com/jazzband/djangorestframework-simplejwt/pull/604
16+
317
## Version 5.2.0
418

519
* Remove the JWTTokenUserAuthentication from the Experimental Features #546 by @byrpatrick in https://github.com/jazzband/djangorestframework-simplejwt/pull/547

docs/experimental_features.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/getting_started.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,19 @@ curl \
9797
...
9898
{"access":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiY29sZF9zdHVmZiI6IuKYgyIsImV4cCI6MTIzNTY3LCJqdGkiOiJjNzE4ZTVkNjgzZWQ0NTQyYTU0NWJkM2VmMGI0ZGQ0ZSJ9.ekxRxgb9OKmHkfy-zs1Ro_xs1eMLXiR17dIDBVxeT-w"}
9999
```
100+
101+
Cryptographic Dependencies (Optional)
102+
-------------------------------------
103+
104+
If you are planning on encoding or decoding tokens using certain digital
105+
signature algorithms (i.e. RSA and ECDSA; visit PyJWT for other algorithms), you will need to install the
106+
cryptography_ library. This can be installed explicitly, or as a required
107+
extra in the `django-ninja-jwt` requirement:
108+
109+
pip install django-ninja-jwt[crypto]
110+
111+
112+
The `django-ninja-jwt[crypto]` format is recommended in requirements
113+
files in projects using `Ninja JWT`, as a separate `cryptography` requirement
114+
line may later be mistaken for an unused requirement and removed.
115+
[cryptography](https://cryptography.io)

docs/settings.md

Lines changed: 138 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -57,192 +57,194 @@ are valid. This `timedelta` value is added to the current UTC time
5757
during token generation to obtain the token's default `exp` claim
5858
value.
5959

60-
`ROTATE_REFRESH_TOKENS`
61-
=======================
60+
``BLACKLIST_AFTER_ROTATION``
61+
----------------------------
6262

63-
When set to `True`, if a refresh token is submitted to the
64-
`TokenRefreshView`, a new refresh token will be returned along with the
65-
new access token. This new refresh token will be supplied via a
66-
`refresh` key in the JSON response. New refresh tokens will have a
67-
renewed expiration time which is determined by adding the timedelta in
68-
the `REFRESH_TOKEN_LIFETIME` setting to the current time when the
69-
request is made. If the blacklist app is in use and the
70-
`BLACKLIST_AFTER_ROTATION` setting is set to `True`, refresh tokens
71-
submitted to the refresh view will be added to the blacklist.
72-
73-
`BLACKLIST_AFTER_ROTATION`
74-
==========================
75-
76-
When set to `True`, causes refresh tokens submitted to the
77-
`TokenRefreshView` to be added to the blacklist if the blacklist app is
78-
in use and the `ROTATE_REFRESH_TOKENS` setting is set to `True`. You
79-
need to add `'ninja_jwt.token_blacklist',` to your `INSTALLED_APPS` in
80-
the settings file to use this setting.
63+
When set to ``True``, causes refresh tokens submitted to the
64+
``TokenRefreshView`` to be added to the blacklist if the blacklist app is in
65+
use and the ``ROTATE_REFRESH_TOKENS`` setting is set to ``True``.
66+
You need to add ``'ninja_jwt.token_blacklist',`` to your
67+
``INSTALLED_APPS`` in the settings file to use this setting.
8168

8269
Learn more about `/blacklist_app`{.interpreted-text role="doc"}.
8370

8471
`UPDATE_LAST_LOGIN`
8572
===================
8673

87-
When set to `True`, last_login field in the auth_user table is updated
88-
upon login (TokenObtainPairController).
74+
When set to ``True``, last_login field in the auth_user table is updated upon
75+
login (TokenObtainPairView).
8976

90-
> Warning: Updating last_login will dramatically increase the number of
91-
> database transactions. People abusing the views could slow the server
92-
> and this could be a security vulnerability. If you really want this,
93-
> throttle the endpoint.
77+
Warning: Updating last_login will dramatically increase the number of database
78+
transactions. People abusing the views could slow the server and this could be
79+
a security vulnerability. If you really want this, throttle the endpoint with
80+
DRF at the very least.
9481

9582
`ALGORITHM`
9683
===========
9784

9885
The algorithm from the PyJWT library which will be used to perform
99-
signing/verification operations on tokens. To use symmetric HMAC signing
100-
and verification, the following algorithms may be used: `'HS256'`,
101-
`'HS384'`, `'HS512'`. When an HMAC algorithm is chosen, the
102-
`SIGNING_KEY` setting will be used as both the signing key and the
103-
verifying key. In that case, the `VERIFYING_KEY` setting will be
104-
ignored. To use asymmetric RSA signing and verification, the following
105-
algorithms may be used: `'RS256'`, `'RS384'`, `'RS512'`. When an RSA
106-
algorithm is chosen, the `SIGNING_KEY` setting must be set to a string
107-
that contains an RSA private key. Likewise, the `VERIFYING_KEY` setting
108-
must be set to a string that contains an RSA public key.
86+
signing/verification operations on tokens. To use symmetric HMAC signing and
87+
verification, the following algorithms may be used: ``'HS256'``, ``'HS384'``,
88+
``'HS512'``. When an HMAC algorithm is chosen, the ``SIGNING_KEY`` setting
89+
will be used as both the signing key and the verifying key. In that case, the
90+
``VERIFYING_KEY`` setting will be ignored. To use asymmetric RSA signing and
91+
verification, the following algorithms may be used: ``'RS256'``, ``'RS384'``,
92+
``'RS512'``. When an RSA algorithm is chosen, the ``SIGNING_KEY`` setting must
93+
be set to a string that contains an RSA private key. Likewise, the
94+
``VERIFYING_KEY`` setting must be set to a string that contains an RSA public
95+
key.
10996

11097
`SIGNING_KEY`
11198
=============
11299

113-
The signing key that is used to sign the content of generated tokens.
114-
For HMAC signing, this should be a random string with at least as many
115-
bits of data as is required by the signing protocol. For RSA signing,
116-
this should be a string that contains an RSA private key that is 2048
117-
bits or longer. Since Ninja JWT defaults to using 256-bit HMAC signing,
118-
the `SIGNING_KEY` setting defaults to the value of the `SECRET_KEY`
119-
setting for your django project. Although this is the most reasonable
120-
default that Ninja JWT can provide, it is recommended that developers
121-
change this setting to a value that is independent from the django
122-
project secret key. This will make changing the signing key used for
100+
The signing key that is used to sign the content of generated tokens. For HMAC
101+
signing, this should be a random string with at least as many bits of data as
102+
is required by the signing protocol. For RSA signing, this should be a string
103+
that contains an RSA private key that is 2048 bits or longer. Since Simple JWT
104+
defaults to using 256-bit HMAC signing, the ``SIGNING_KEY`` setting defaults to
105+
the value of the ``SECRET_KEY`` setting for your django project. Although this
106+
is the most reasonable default that Simple JWT can provide, it is recommended
107+
that developers change this setting to a value that is independent from the
108+
django project secret key. This will make changing the signing key used for
123109
tokens easier in the event that it is compromised.
124110

125111
`VERIFYING_KEY`
126112
===============
127113

128-
The verifying key which is used to verify the content of generated
129-
tokens. If an HMAC algorithm has been specified by the `ALGORITHM`
130-
setting, the `VERIFYING_KEY` setting will be ignored and the value of
131-
the `SIGNING_KEY` setting will be used. If an RSA algorithm has been
132-
specified by the `ALGORITHM` setting, the `VERIFYING_KEY` setting must
133-
be set to a string that contains an RSA public key.
114+
The verifying key which is used to verify the content of generated tokens. If
115+
an HMAC algorithm has been specified by the ``ALGORITHM`` setting, the
116+
``VERIFYING_KEY`` setting will be ignored and the value of the ``SIGNING_KEY``
117+
setting will be used. If an RSA algorithm has been specified by the
118+
``ALGORITHM`` setting, the ``VERIFYING_KEY`` setting must be set to a string
119+
that contains an RSA public key.
134120

135121
`AUDIENCE`
136122
==========
137123

138-
The audience claim to be included in generated tokens and/or validated
139-
in decoded tokens. When set to `None`, this field is excluded from
140-
tokens and is not validated.
124+
The audience claim to be included in generated tokens and/or validated in
125+
decoded tokens. When set to ``None``, this field is excluded from tokens and is
126+
not validated.
141127

142128
`ISSUER`
143129
========
144130

145-
The issuer claim to be included in generated tokens and/or validated in
146-
decoded tokens. When set to `None`, this field is excluded from tokens
147-
and is not validated.
131+
The issuer claim to be included in generated tokens and/or validated in decoded
132+
tokens. When set to ``None``, this field is excluded from tokens and is not
133+
validated.
148134

149-
`JWK_URL`
150-
=========
151-
The JWK_URL is used to dynamically resolve the public keys needed to
152-
verify the signing of tokens. When using Auth0 for example you might set
153-
this to '<https://yourdomain.auth0.com/.well-known/jwks.json>'. When
154-
set to `None`, this field is excluded from the token backend and is not
155-
used during validation.
135+
``JWK_URL``
136+
----------
156137

157-
`LEEWAY`
158-
========
138+
The JWK_URL is used to dynamically resolve the public keys needed to verify the
139+
signing of tokens. When using Auth0 for example you might set this to
140+
'https://yourdomain.auth0.com/.well-known/jwks.json'. When set to ``None``,
141+
this field is excluded from the token backend and is not used during
142+
validation.
159143

160-
Leeway is used to give some margin to the expiration time. This can be
161-
an integer for seconds or a `datetime.timedelta`. Please reference
162-
<https://pyjwt.readthedocs.io/en/latest/usage.html#expiration-time-claim-exp>
144+
``LEEWAY``
145+
----------
146+
147+
Leeway is used to give some margin to the expiration time. This can be an
148+
integer for seconds or a ``datetime.timedelta``. Please reference
149+
https://pyjwt.readthedocs.io/en/latest/usage.html#expiration-time-claim-exp
163150
for more information.
164151

165-
`USER_ID_FIELD`
166-
===============
152+
``AUTH_HEADER_TYPES``
153+
---------------------
167154

168-
The database field from the user model that will be included in
169-
generated tokens to identify users. It is recommended that the value of
170-
this setting specifies a field that does not normally change once its
171-
initial value is chosen. For example, specifying a `username` or
172-
`email` field would be a poor choice since an account's username or
173-
email might change depending on how account management in a given
174-
service is designed. This could allow a new account to be created with
175-
an old username while an existing token is still valid which uses that
176-
username as a user identifier.
177-
178-
`USER_ID_CLAIM`
179-
===============
155+
The authorization header type(s) that will be accepted for views that require
156+
authentication. For example, a value of ``'Bearer'`` means that views
157+
requiring authentication would look for a header with the following format:
158+
``Authorization: Bearer <token>``. This setting may also contain a list or
159+
tuple of possible header types (e.g. ``('Bearer', 'JWT')``). If a list or
160+
tuple is used in this way, and authentication fails, the first item in the
161+
collection will be used to build the "WWW-Authenticate" header in the response.
180162

181-
The claim in generated tokens which will be used to store user
182-
identifiers. For example, a setting value of `'user_id'` would mean
183-
generated tokens include a `user_id` claim that contains the user's
184-
identifier.
163+
``AUTH_HEADER_NAME``
164+
----------------------------
185165

186-
`USER_AUTHENTICATION_RULE`
187-
==========================
166+
The authorization header name to be used for authentication.
167+
The default is ``HTTP_AUTHORIZATION`` which will accept the
168+
``Authorization`` header in the request. For example if you'd
169+
like to use ``X_Access_Token`` in the header of your requests
170+
please specify the ``AUTH_HEADER_NAME`` to be
171+
``HTTP_X_ACCESS_TOKEN`` in your settings.
188172

189-
Callable to determine if the user is permitted to authenticate. This
190-
rule is applied after a valid token is processed. The user object is
191-
passed to the callable as an argument. The default rule is to check that
192-
the `is_active` flag is still `True`. The callable must return a
193-
boolean, `True` if authorized, `False` otherwise resulting in a 401
194-
status code.
173+
``USER_ID_FIELD``
174+
-----------------
195175

196-
`AUTH_TOKEN_CLASSES`
197-
====================
176+
The database field from the user model that will be included in generated
177+
tokens to identify users. It is recommended that the value of this setting
178+
specifies a field that does not normally change once its initial value is
179+
chosen. For example, specifying a "username" or "email" field would be a poor
180+
choice since an account's username or email might change depending on how
181+
account management in a given service is designed. This could allow a new
182+
account to be created with an old username while an existing token is still
183+
valid which uses that username as a user identifier.
198184

199-
A list of dot paths to classes that specify the types of token that are
200-
allowed to prove authentication. More about this in the `Token types`
201-
section below.
185+
``USER_ID_CLAIM``
186+
-----------------
202187

203-
`TOKEN_TYPE_CLAIM`
204-
==================
188+
The claim in generated tokens which will be used to store user identifiers.
189+
For example, a setting value of ``'user_id'`` would mean generated tokens
190+
include a "user_id" claim that contains the user's identifier.
205191

206-
The claim name that is used to store a token's type. More about this in
207-
the `Token types` section below.
192+
``USER_AUTHENTICATION_RULE``
193+
----------------------------
208194

209-
`JTI_CLAIM`
210-
===========
195+
Callable to determine if the user is permitted to authenticate. This rule
196+
is applied after a valid token is processed. The user object is passed
197+
to the callable as an argument. The default rule is to check that the ``is_active``
198+
flag is still ``True``. The callable must return a boolean, ``True`` if authorized,
199+
``False`` otherwise resulting in a 401 status code.
211200

212-
The claim name that is used to store a token's unique identifier. This
213-
identifier is used to identify revoked tokens in the blacklist app. It
214-
may be necessary in some cases to use another claim besides the default
215-
`jti` claim to store such a value.
201+
``AUTH_TOKEN_CLASSES``
202+
----------------------
216203

217-
`TOKEN_USER_CLASS`
218-
==================
204+
A list of dot paths to classes that specify the types of token that are allowed
205+
to prove authentication. More about this in the "Token types" section below.
219206

220-
A stateless user object which is backed by a validated token. Used only
221-
for the experimental JWTTokenUserAuthentication authentication backend.
222-
The value is a dotted path to your subclass of
223-
`rest_framework_simplejwt.models.TokenUser`, which also is the default.
207+
``TOKEN_TYPE_CLAIM``
208+
--------------------
224209

225-
`SLIDING_TOKEN_LIFETIME`
226-
========================
210+
The claim name that is used to store a token's type. More about this in the
211+
"Token types" section below.
212+
213+
``JTI_CLAIM``
214+
-------------
215+
216+
The claim name that is used to store a token's unique identifier. This
217+
identifier is used to identify revoked tokens in the blacklist app. It may be
218+
necessary in some cases to use another claim besides the default "jti" claim to
219+
store such a value.
220+
221+
``TOKEN_USER_CLASS``
222+
--------------------
223+
224+
A stateless user object which is backed by a validated token. Used only for
225+
the JWTStatelessUserAuthentication authentication backend. The value
226+
is a dotted path to your subclass of ``rest_framework_simplejwt.models.TokenUser``,
227+
which also is the default.
228+
229+
``SLIDING_TOKEN_LIFETIME``
230+
--------------------------
231+
232+
A ``datetime.timedelta`` object which specifies how long sliding tokens are
233+
valid to prove authentication. This ``timedelta`` value is added to the
234+
current UTC time during token generation to obtain the token's default "exp"
235+
claim value. More about this in the "Sliding tokens" section below.
227236

228-
A `datetime.timedelta` object which specifies how long sliding tokens
229-
are valid to prove authentication. This `timedelta` value is added to
230-
the current UTC time during token generation to obtain the token's
231-
default `exp` claim value. More about this in the `Sliding tokens`
232-
section below.
237+
``SLIDING_TOKEN_REFRESH_LIFETIME``
238+
----------------------------------
233239

234-
`SLIDING_TOKEN_REFRESH_LIFETIME`
235-
================================
240+
A ``datetime.timedelta`` object which specifies how long sliding tokens are
241+
valid to be refreshed. This ``timedelta`` value is added to the current UTC
242+
time during token generation to obtain the token's default "exp" claim value.
243+
More about this in the "Sliding tokens" section below.
236244

237-
A `datetime.timedelta` object which specifies how long sliding tokens
238-
are valid to be refreshed. This `timedelta` value is added to the
239-
current UTC time during token generation to obtain the token's default
240-
`exp` claim value. More about this in the `Sliding tokens` section
241-
below.
245+
``SLIDING_TOKEN_REFRESH_EXP_CLAIM``
246+
-----------------------------------
242247

243-
`SLIDING_TOKEN_REFRESH_EXP_CLAIM`
244-
=================================
248+
The claim name that is used to store the expiration time of a sliding token's
249+
refresh period. More about this in the "Sliding tokens" section below.
245250

246-
The claim name that is used to store the expiration time of a sliding
247-
token's refresh period. More about this in the `Sliding tokens`
248-
section below.

0 commit comments

Comments
 (0)