Using django-rest-knox

Alexis Chilinski
1 min readJun 1, 2020

--

When I first started learning Django, I focused mainly on the built-in tools in the django-rest-framework library. It has many, but one of the main tools is Token Authentication. I could have figured out how to use this built-in tool, but after some research, it turns out django-rest-knox can be a much more preferable library. It can be a more secure token authentication option for these reasons:

In django-rest-framework, each user is only permitted one token. So if you’re signing in on multiple devices, it won’t be very secure. And when logging out, all devices will be logged out. However, with django-rest-knox, users are allowed multiple tokens for signing in on multiple devices. Users also have the option to log out of all devices at once, but it’s not necessary.

Django-rest-framework passwords are not stored encrypted, but passwords through django-rest-knox are. Passwords are much more secure if they’re encrypted, so if someone were to hack into the database, they wouldn’t be able to decrypt the passwords and have access to user data.

Everyone has their own preferences. Django-rest-framework does have the built-in capability for token authentication so you only have to install that one library for many uses. But if you’re looking for more secure authentication, django-rest-knox would be the way to go.

--

--