Skip to content

Commit

Permalink
Check if session user is same as logged user
Browse files Browse the repository at this point in the history
  • Loading branch information
veteran29 committed Nov 6, 2023
1 parent 14046a4 commit d608327
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Security/Authenticator/OryKratosAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public function authenticate(Request $request): Passport

// keep current user if we're only checking if the Ory Kratos session has not expired
if ($this->checkSession && $user = $this->security->getUser()) {
// handle user switching accounts outside our application
if ($this->loadUser($session->getIdentity()->getId(), $session)->getUserIdentifier() !== $user->getUserIdentifier()) {
throw new AuthenticationException('Session user not equal application user!');
}

return new SelfValidatingPassport(
new UserBadge(
$user->getUserIdentifier(),
Expand Down

0 comments on commit d608327

Please sign in to comment.