From ca9efa5702553e5f46e4965b467f2ca1fc41737b Mon Sep 17 00:00:00 2001 From: SeoJimin1234 <113419021+SeoJimin1234@users.noreply.github.com> Date: Sat, 6 Jan 2024 16:47:37 +0900 Subject: [PATCH] fix: Make Login Session (#12) Co-authored-by: SeoJimin --- UpcyProject/settings.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/UpcyProject/settings.py b/UpcyProject/settings.py index a239561..d7472f0 100644 --- a/UpcyProject/settings.py +++ b/UpcyProject/settings.py @@ -10,6 +10,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/ """ +from datetime import timedelta from pathlib import Path import environ import os @@ -71,6 +72,30 @@ AUTH_USER_MODEL = "users.User" +ACCOUNT_USER_MODEL_USERNAME_FIELD = None +ACCOUNT_EMAIL_REQUIRED = True +ACCOUNT_USERNAME_REQUIRED = False +ACCOUNT_AUTHENTICATION_METHOD = 'email' + +REST_FRAMEWORK = { + "DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated", ], + "DEFAULT_AUTHENTICATION_CLASSES": [ + "rest_framework_simplejwt.authentication.JWTAuthentication", + "rest_framework.authentication.TokenAuthentication", + "rest_framework.authentication.SessionAuthentication", + ], +} + +REST_USE_JWT = True + +SIMPLE_JWT = { + 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=10), + 'REFRESH_TOKEN_LIFETIME': timedelta(days=28), + 'ROTATE_REFRESH_TOKENS': False, # true면 토큰 갱신 시 refresh도 같이 갱신 + 'BLACKLIST_AFTER_ROTATION': True, +} + + ROOT_URLCONF = 'UpcyProject.urls' TEMPLATES = [