Skip to content

Commit 4335c65

Browse files
committed
refactor(auth): clear oauth state after validation
1 parent 304a635 commit 4335c65

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/auth/src/OAuth/GenericOAuthClient.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ public function fetchUser(AccessToken $token): OAuthUser
100100

101101
public function authenticate(Request $request, Closure $map): Authenticatable
102102
{
103-
if ($this->session->get($this->sessionKey) !== $request->get('state')) {
103+
$expectedState = $this->session->get($this->sessionKey);
104+
$actualState = $request->get('state');
105+
106+
$this->session->remove($this->sessionKey);
107+
108+
if ($expectedState !== $actualState) {
104109
throw new OAuthStateWasInvalid();
105110
}
106111

0 commit comments

Comments
 (0)