Skip to main content

Simple JWT.

Project description

**JWTiTIC**
This library is a simple method for authentication in microservices using JWT

**Requirements**

------------

* Python (2.7, 3.3, 3.4, 3.5, 3.6)
* Django (1.8, 1.9, 1.10, 1.11)
* Django REST Framework (3.1, 3.2, 3.3, 3.4, 3.5, 3.6)


**Installation**

You need djangorestframework-jwt.
<pre>$ pip install djangorestframework-jwt</pre>

Install using pip.
<pre>$ pip install jwti2tic</pre>

Add 'jwtauth' to your INSTALLED_APPS setting.
```
INSTALLED_APPS = (
...
'jwtauth',
)
```
Add 'DEFAULT_AUTHENTICATION_CLASSES' to your REST_FRAMEWORK settings.
```
REST_FRAMEWORK = {

'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'jwtauth.drfjwtauth.JWTAuthentication'
)
}
```
Add 'CUSTOM JWT_PAYLOAD_HANDLER' to your JWT_AUTH settings.
```

JWT_AUTH = {
'JWT_PAYLOAD_GET_USERNAME_HANDLER': 'jwtauth.utils.jwt_get_user_name_from_payload_handler',
'JWT_PAYLOAD_GET_USER_ID_HANDLER': 'jwtauth.utils.jwt_get_user_id_from_payload_handler',
}
```

**Usage**

* In your .views import these packages.
```
from rest_framework.authentication import BasicAuthentication, SessionAuthentication
from rest_framework.permissions import IsAuthenticated
from jwtauth.drfjwtauth import JWTAuthentication
```

* Inside your vieset class, add this settings.
```
authentication_classes = (SessionAuthentication, BasicAuthentication, JWTAuthentication)
permission_classes = (IsAuthenticated,)
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for jwt-i2tic, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size jwt-i2tic-0.2.1.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page