Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sécurité] Historisation des connexions à la plateforme #2742

Merged
merged 9 commits into from
Jun 28, 2024

Conversation

emilschn
Copy link
Collaborator

@emilschn emilschn commented Jun 27, 2024

Ticket

#728

Description

Historisation de l'ensemble des accès à la plateforme

Changements apportés

  • Création d'une table HistoryEntry qui stocke l'ensemble des logins au SI
  • A terme, elle permettra de stocker l'ensemble des événements de modification du site

Pré-requis

make execute-migration name=Version20240624153853 direction=up

Tests

  • Se logger avec différents utilisateurs et vérifier qu'une ligne s'ajoute dans la table history_entry

@emilschn emilschn changed the title [WIP] Log [Sécurité] Historisation des connexions à la plateforme Jun 27, 2024
@emilschn emilschn marked this pull request as ready for review June 27, 2024 16:00
Copy link
Collaborator

@hmeneuvrier hmeneuvrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ça marche très bien, mais quelques questions

src/EventListener/LoginListener.php Outdated Show resolved Hide resolved
src/Entity/HistoryEntry.php Show resolved Hide resolved
src/EventListener/LoginListener.php Outdated Show resolved Hide resolved
src/Entity/HistoryEntry.php Show resolved Hide resolved
src/Factory/HistoryEntryFactory.php Outdated Show resolved Hide resolved
src/EventListener/LoginListener.php Outdated Show resolved Hide resolved
user: $user
);
}

$this->requestStack->getSession()->set('_security.territory', $user->getTerritory());
Copy link
Collaborator

@sfinx13 sfinx13 Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Juste pour éviter de prêter à confusion utiliser une seule ressource pour récupérer la requête. Vu qu'elle est dispo dans l'event je propose de s'appuyer uniquement sur $event->getRequest() et supprimer l'utilisateur l'utilisation de $requestStack

Copy link
Collaborator Author

@emilschn emilschn Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pas tout à fait sûr de comprendre.
Est-ce que ce que j'ai modifié correspond à ce que tu proposes ?
(et dans ce cas, tu voulais peut-être dire "utilisation" plutôt que "utilisateur" ?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ça correspond bien mais à la ligne 39 je vois qu'il y'a le service $requestStack qui est injecté ça fait redondant avec $event->getRequest()

Remplacer

 $this->requestStack->getSession()->set('_security.territory', $user->getTerritory());

par

$request = $event->getRequest();
if (self::CHECK_2FA_PATH !== $request->getPathInfo()) {
 // .....
}
$request->getSession()->set('_security.territory', $user->getTerritory());

Copy link
Collaborator

@sfinx13 sfinx13 Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu as bien appliqué la modif donc c'est tout bon

Copy link

sonarcloud bot commented Jun 28, 2024

Copy link
Collaborator

@hmeneuvrier hmeneuvrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relecture et retests OK pour moi

Copy link
Collaborator

@sfinx13 sfinx13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lecture et test OK

@sfinx13 sfinx13 merged commit f48eb4c into develop Jun 28, 2024
3 checks passed
@sfinx13 sfinx13 deleted the feature/728-db-log branch June 28, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants