forked from jazzband/djangorestframework-simplejwt
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
seperated experiment token from actual token authentication
- Loading branch information
1 parent
9ea76aa
commit 21fc49c
Showing
5 changed files
with
28 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,22 @@ | ||
subtitle: JWTTokenUserAuthentication backend | ||
title: Experimental features | ||
--- | ||
|
||
The `JWTTokenUserAuthentication` backend\'s `authenticate` method does | ||
The `JWTTokenUserAuth` backend\'s `authenticate` method does | ||
not perform a database lookup to obtain a user instance. Instead, it | ||
returns a `ninja_jwt.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 | ||
`ninja_jwt.authentication.JWTTokenUserAuthentication` backend (instead | ||
of the default `JWTAuthentication` backend) to the Django REST | ||
Framework\'s `DEFAULT_AUTHENTICATION_CLASSES` config setting: | ||
`ninja_jwt.authentication.JWTTokenUserAuth` backend (instead | ||
of the default `JWTAuth` backend) to the Django Ninja Extra route definition | ||
|
||
```python | ||
REST_FRAMEWORK = { | ||
... | ||
'DEFAULT_AUTHENTICATION_CLASSES': ( | ||
... | ||
'ninja_jwt.authentication.JWTTokenUserAuthentication', | ||
) | ||
... | ||
} | ||
from ninja_extra import APIController, router, route | ||
from ninja_jwt.authentication import JWTTokenUserAuth | ||
|
||
@router('') | ||
class MyController(APIController): | ||
@route.get('/some-endpoint', auth=JWTTokenUserAuth()) | ||
def some_endpoint(self): | ||
pass | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters