Skip to content

Commit 3e48895

Browse files
committed
fix: JWT Authenticator raw tokens are logged
1 parent b0b10b6 commit 3e48895

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/Authentication/Authenticators/JWT.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function attempt(array $credentials): Result
103103
// Record a banned login attempt.
104104
$this->tokenLoginModel->recordLoginAttempt(
105105
self::ID_TYPE_JWT,
106-
$credentials['token'] ?? '',
106+
'sha256:' . hash('sha256', $credentials['token'] ?? ''),
107107
false,
108108
$ipAddress,
109109
$userAgent,
@@ -125,7 +125,7 @@ public function attempt(array $credentials): Result
125125
// Record a successful login attempt.
126126
$this->tokenLoginModel->recordLoginAttempt(
127127
self::ID_TYPE_JWT,
128-
$credentials['token'] ?? '',
128+
'sha256:' . hash('sha256', $credentials['token']),
129129
true,
130130
$ipAddress,
131131
$userAgent,

tests/Authentication/Authenticators/JWTAuthenticatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public function testAttemptBannedUser(): void
226226
// The login attempt should have been recorded
227227
$this->seeInDatabase('auth_token_logins', [
228228
'id_type' => JWT::ID_TYPE_JWT,
229-
'identifier' => $token,
229+
'identifier' => 'sha256:' . hash('sha256', $token),
230230
'success' => 0,
231231
'user_id' => $this->user->id,
232232
]);
@@ -256,7 +256,7 @@ public function testAttemptSuccess(): void
256256
// A login attempt should have been recorded
257257
$this->seeInDatabase('auth_token_logins', [
258258
'id_type' => JWT::ID_TYPE_JWT,
259-
'identifier' => $token,
259+
'identifier' => 'sha256:' . hash('sha256', $token),
260260
'success' => 1,
261261
]);
262262
}

0 commit comments

Comments
 (0)