File: stateless_user_authentication.rst

package info (click to toggle)
python-djangorestframework-simplejwt 5.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 956 kB
  • sloc: python: 3,783; makefile: 213; javascript: 40; sh: 6
file content (32 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
.. _stateless_user_authentication:

Stateless User Authentication
=============================

JWTStatelessUserAuthentication backend
--------------------------------------

The ``JWTStatelessUserAuthentication`` backend's ``authenticate`` method does not
perform a database lookup to obtain a user instance.  Instead, it returns a
``rest_framework_simplejwt.models.TokenUser`` instance which acts as a
stateless user object backed only by a validated token instead of a record in a
database.  This can facilitate developing single sign-on functionality between
separately hosted Django apps which all share the same token secret key.  To
use this feature, add the
``rest_framework_simplejwt.authentication.JWTStatelessUserAuthentication`` backend
(instead of the default ``JWTAuthentication`` backend) to the Django REST
Framework's ``DEFAULT_AUTHENTICATION_CLASSES`` config setting:

.. code-block:: python

  REST_FRAMEWORK = {
      ...
      'DEFAULT_AUTHENTICATION_CLASSES': (
          ...
          'rest_framework_simplejwt.authentication.JWTStatelessUserAuthentication',
      )
      ...
  }
  
v5.1.0 has renamed ``JWTTokenUserAuthentication`` to ``JWTStatelessUserAuthentication``, 
but both names are supported for backwards compatibility