diff --git a/apps/authentication/api/mfa.py b/apps/authentication/api/mfa.py index 4ba5665d4..c02970608 100644 --- a/apps/authentication/api/mfa.py +++ b/apps/authentication/api/mfa.py @@ -18,7 +18,7 @@ from common.utils import get_logger from users.models.user import User from .. import errors from .. import serializers -from ..const import MFA_FACE_CONTEXT_CACHE_KEY_PREFIX, MFA_FACE_SESSION_KEY +from ..const import MFA_FACE_CONTEXT_CACHE_KEY_PREFIX, MFA_FACE_SESSION_KEY, MFA_FACE_CONTEXT_CACHE_TTL from ..errors import SessionEmptyError from ..mixins import AuthMixin @@ -74,7 +74,7 @@ class MFAFaceCallbackApi(AuthMixin, CreateAPIView): def _update_cache(self, context): cache_key = self.get_face_cache_key(context['token']) - cache.set(cache_key, context, 3600) + cache.set(cache_key, context, MFA_FACE_CONTEXT_CACHE_TTL) def _handle_success(self, context, face_code): context.update({ @@ -100,7 +100,7 @@ class MFAFaceContextApi(AuthMixin, RetrieveAPIView, CreateAPIView): "token": token, "is_finished": False } - cache.set(cache_key, face_context) + cache.set(cache_key, face_context, MFA_FACE_CONTEXT_CACHE_TTL) self.request.session[self.face_token_session_key] = token return token diff --git a/apps/authentication/const.py b/apps/authentication/const.py index 1a27889f1..927f6d204 100644 --- a/apps/authentication/const.py +++ b/apps/authentication/const.py @@ -41,4 +41,5 @@ class MFAType(TextChoices): MFA_FACE_CONTEXT_CACHE_KEY_PREFIX = "MFA_FACE_RECOGNITION_CONTEXT" +MFA_FACE_CONTEXT_CACHE_TTL = 60 MFA_FACE_SESSION_KEY = "mfa_face_token"