Skip to content

Commit

Permalink
Merge pull request #234 from antaliadom-team/feature/jwt_lifetime
Browse files Browse the repository at this point in the history
add jwt lifetime env settings
  • Loading branch information
spaut33 committed May 28, 2023
2 parents d09961a + 6f27da9 commit 0b52c34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 0 additions & 11 deletions antalia_project/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from datetime import timedelta

# настройки валидации паролей
AUTH_PASSWORD_VALIDATORS = [
{
Expand Down Expand Up @@ -30,15 +28,6 @@
],
}

# настройки simple-jwt
SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': timedelta(days=1),
'REFRESH_TOKEN_LIFETIME': timedelta(days=7),
'AUTH_HEADER_TYPES': ('Bearer',),
'ROTATE_REFRESH_TOKENS': True,
'BLACKLIST_AFTER_ROTATION': True,
}

# настройки Djoser
DJOSER = {
'LOGIN_FIELD': 'email',
Expand Down
14 changes: 14 additions & 0 deletions antalia_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import timedelta
import os
from pathlib import Path

Expand Down Expand Up @@ -173,3 +174,16 @@
'OPTIONS': {'CLIENT_CLASS': 'django_redis.client.DefaultClient'},
}
}

# настройки simple-jwt
SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': timedelta(
minutes=int(os.getenv('ACCESS_TOKEN_LIFETIME_MINUTES', default=5))
),
'REFRESH_TOKEN_LIFETIME': timedelta(
minutes=int(os.getenv('REFRESH_TOKEN_LIFETIME_MINUTES', default=360))
),
'AUTH_HEADER_TYPES': ('Bearer',),
'ROTATE_REFRESH_TOKENS': True,
'BLACKLIST_AFTER_ROTATION': True,
}

0 comments on commit 0b52c34

Please sign in to comment.