Skip to content

Commit bc3e329

Browse files
committed
Add DRF JWT authentication
1 parent e7b00d3 commit bc3e329

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ Simple boilerplate for django & django rest framework
77

88
### Tasks list
99
- [x] Users api CRUD endpoints
10-
- [ ] DRF JWT Authentication
10+
- [x] DRF JWT Authentication
11+
- [ ] Add docker configurations
1112
- [ ] Document folder structure
1213
- [ ] Configure Static/media & templates
13-
- [ ] Add docker configurations
1414
- [ ] Integrate material ui & react js on templates
15+
16+
#### Jwt token endpoint
17+
Method | Endpoint | Functionanlity
18+
--- | --- | ---
19+
POST | `/api-token-auth` | Request jwt token
1520

1621
#### User Endpoints
1722

configurations/settings.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,15 @@
128128
# https://docs.djangoproject.com/en/2.1/howto/static-files/
129129

130130
STATIC_URL = '/static/'
131+
132+
REST_FRAMEWORK = {
133+
'DEFAULT_PERMISSION_CLASSES': (
134+
'rest_framework.permissions.IsAuthenticated',
135+
),
136+
'DEFAULT_AUTHENTICATION_CLASSES': (
137+
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
138+
'rest_framework.authentication.SessionAuthentication',
139+
'rest_framework.authentication.BasicAuthentication',
140+
),
141+
}
142+

configurations/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from django.contrib import admin
22
from django.urls import path, include
3+
from rest_framework_jwt.views import obtain_jwt_token
34

45
urlpatterns = [
56
path('admin/', admin.site.urls),
67
path('api-auth/', include('rest_framework.urls', namespace='rest')),
8+
path('api-token-auth', obtain_jwt_token),
79
path('user/', include(('app_dir.user.urls', 'user'), namespace='user')),
810
path('user/api/', include(('app_dir.user.api.urls', 'user_api'), namespace='user_api'))
911
]
12+

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ coveralls==1.5.1
55
Django==2.1.2
66
django-filter==2.0.0
77
djangorestframework==3.8.2
8+
djangorestframework-jwt==1.11.0
89
docopt==0.6.2
910
idna==2.7
1011
Markdown==3.0.1
12+
PyJWT==1.6.4
1113
pytz==2018.5
1214
requests==2.19.1
1315
urllib3==1.23

0 commit comments

Comments
 (0)