Skip to content

Commit

Permalink
fix: ajout de logs plus fins pour les connexions directes
Browse files Browse the repository at this point in the history
Ajouter une action dans le corps du log permettra de contruire un
tableau de suivi plus facilement (les actions relatives à la connexion
directe sont catégorisées).
  • Loading branch information
ikarius committed Dec 23, 2024
1 parent 4b577b2 commit 73a4864
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions back/dora/auth_links/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import enum


class AuthLinkAction(enum.StrEnum):
"""
Actions loggées pour les liens d'identifications.
"""

SENT_AUTH_LINK = "sent_auth_link"
DID_AUTHENTICATE_WITH_AUTH_LINK = "did_authenticate_with_auth_link"
USED_EXPIRED_AUTH_LINK = "used_expired_auth_link"
8 changes: 7 additions & 1 deletion back/dora/auth_links/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from sesame.utils import get_token, get_user

from dora.auth_links.emails import send_authentication_link
from dora.auth_links.enums import AuthLinkAction
from dora.users.models import User

logger = logging.getLogger("dora.logs.core")
Expand Down Expand Up @@ -38,6 +39,7 @@ def send_link(request):
"Demande de connexion par lien direct",
{
"legal": True,
"action": AuthLinkAction.SENT_AUTH_LINK,
"userId": user.pk,
"userEmail": user.email,
},
Expand All @@ -53,6 +55,7 @@ def authenticate_with_link(request, sesame):
"Connexion par lien direct",
{
"legal": True,
"action": AuthLinkAction.DID_AUTHENTICATE_WITH_AUTH_LINK,
"userId": user.pk,
"userEmail": user.email,
},
Expand All @@ -68,7 +71,10 @@ def authenticate_with_link(request, sesame):

logger.warning(
"Lien direct invalide ou expiré",
{"sesameLink": f"...{sesame[:-5]}"},
{
"action": AuthLinkAction.USED_EXPIRED_AUTH_LINK,
"sesameLink": f"...{sesame[:-5]}",
},

Check failure

Code scanning / CodeQL

Log Injection High

This log entry depends on a
user-provided value
.
)

# le lien est invalide ou expiré :
Expand Down

0 comments on commit 73a4864

Please sign in to comment.