Skip to content
This repository has been archived by the owner on Aug 1, 2021. It is now read-only.

Commit

Permalink
CSRF tokens are deleted from the session after they've been consumed
Browse files Browse the repository at this point in the history
  • Loading branch information
o-alquimista committed Oct 5, 2019
1 parent 25a3a00 commit a45fdf8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Fragments/Component/Security/Csrf/CsrfTokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,15 @@ public function isTokenValid($tokenReceived, $id)
}

$tokenStored = $this->session->get($tokenName);
$tokenValid = hash_equals($tokenStored, $tokenReceived);

return hash_equals($tokenStored, $tokenReceived);
if ($tokenValid) {
$this->session->destroy($tokenName);

return true;
}

return false;
}

private function generate()
Expand Down

0 comments on commit a45fdf8

Please sign in to comment.