Microservices Classroomnotes 28/Dec/2021

JWT Authorization with Django REST Framework

  • Django restframework authentication Refer Here for the official docs
  • Refer Here for django-jwt documentation
  • Install the package
pip install djangorestframework-simplejwt
  • Now add the following to the settings.py
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ]
}
  • For the API View we can set the permissions at the class level
  • Now lets create a UserCreateApiView and use the exising auth_users class for serialization.
  • Refer Here for the changes done in the classroom
  • Next steps:
  • Implement JWT Token based authentication
  • Implement Blacklisting
  • Implementing refresh tokens

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner