Skip to content

AliReza7222/Authentication_JWT_DRF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Authentication_JWT_DRF


Authentication based on Json Web Token or synonym JWT.

In this repository I tried to create a jwt based authentication with django rest framework or DRF .


Install packages

Install packages in requirement.txt

command :
  pip install -r requirement.txt

Custom User

First i created a Custom model User for register User and config in settings with AUTH_USER_MODEL .


Login

Second stage User must log in for continue in site so send request to endpoint or url '/api/accounts/login/' and enter email and password valid .

Then with package djangorestframework-simplejwt create a jwt token contains refresh token and access token .

These tokens contain a LifeTime that is set in the settings in the SIMPLE_JWT variable.


Change Password

Authentication Default RestFramework changed to JWTAuthentication in settings in variable REST_FRAMEWORK .

For Change Password User you must login Before, so i used Permission IsAuthenticated in this View.

IsAuthenticated checks the header for an access token, returning an error if invalid.

if validated everything's your password successfully changed and in this view used method PUT .



About

Authentication based on Json Web Token or JWT.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages