forked from City-of-Helsinki/parkkihubi
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API endpoints for JWT authentication
- Loading branch information
1 parent
5839c11
commit a0431f1
Showing
5 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import drf_jwt_2fa.urls | ||
from django.conf.urls import include, url | ||
|
||
v1_urlpatterns = [ | ||
url(r'^', include(drf_jwt_2fa.urls, namespace='auth')), | ||
] | ||
|
||
urlpatterns = [ | ||
url(r'^', include(v1_urlpatterns, namespace='v1')), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,6 +153,7 @@ | |
vars().update(env.email_url( | ||
default=('consolemail://' if DEBUG else 'smtp://localhost:25') | ||
)) | ||
DEFAULT_FROM_EMAIL = '[email protected]' | ||
|
||
######################### | ||
# Django REST Framework # | ||
|
@@ -165,6 +166,7 @@ | |
], | ||
'DEFAULT_AUTHENTICATION_CLASSES': [ | ||
'parkings.authentication.ApiKeyAuthentication', | ||
'drf_jwt_2fa.authentication.Jwt2faAuthentication', | ||
] + ([ # Following two are only for DEBUG mode in dev environment: | ||
'rest_framework.authentication.SessionAuthentication', | ||
'rest_framework.authentication.BasicAuthentication', | ||
|
@@ -178,6 +180,24 @@ | |
'TEST_REQUEST_DEFAULT_FORMAT': 'json', | ||
} | ||
|
||
JWT_AUTH = { | ||
'JWT_EXPIRATION_DELTA': timedelta(minutes=30), | ||
'JWT_ALLOW_REFRESH': True, | ||
'JWT_REFRESH_EXPIRATION_DELTA': timedelta(days=7), | ||
} | ||
|
||
JWT2FA_AUTH = { | ||
'CODE_TOKEN_THROTTLE_RATE': '5/15m', | ||
'AUTH_TOKEN_RETRY_WAIT_TIME': timedelta(seconds=10), | ||
'EMAIL_SENDER_SUBJECT_OVERRIDE': '{code} - Varmennuskoodisi', | ||
'EMAIL_SENDER_BODY_OVERRIDE': ( | ||
'Hei!\n' | ||
'\n' | ||
'Varmennuskoodisi kirjautumista varten on: {code}\n' | ||
'\n' | ||
't. Parkkihubi'), | ||
} | ||
|
||
CORS_ORIGIN_ALLOW_ALL = True | ||
|
||
############## | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ psycopg2 | |
djangorestframework | ||
djangorestframework-gis | ||
django-filter | ||
drf-jwt-2fa | ||
|
||
# XML parsing | ||
lxml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters