Skip to content

Commit fef02d1

Browse files
omerimzalikenjis
authored andcommitted
supportOldDangerousPassword support removed
1 parent d1d1f96 commit fef02d1

4 files changed

Lines changed: 2 additions & 65 deletions

File tree

src/Authentication/Authenticators/Session.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -343,30 +343,20 @@ public function check(array $credentials): Result
343343
/** @var Passwords $passwords */
344344
$passwords = service('passwords');
345345

346-
// This is only for supportOldDangerousPassword.
347-
$needsRehash = false;
348-
349346
// Now, try matching the passwords.
350347
if (! $passwords->verify($givenPassword, $user->password_hash)) {
351-
if (
352-
! setting('Auth.supportOldDangerousPassword')
353-
|| ! $passwords->verifyDanger($givenPassword, $user->password_hash) // @phpstan-ignore-line
354-
) {
355348
return new Result([
356349
'success' => false,
357350
'reason' => lang('Auth.invalidPassword'),
358351
]);
359-
}
360-
361-
// Passed with old dangerous password.
362-
$needsRehash = true;
352+
363353
}
364354

365355
// Check to see if the password needs to be rehashed.
366356
// This would be due to the hash algorithm or hash
367357
// cost changing since the last time that a user
368358
// logged in.
369-
if ($passwords->needsRehash($user->password_hash) || $needsRehash) {
359+
if ($passwords->needsRehash($user->password_hash)) {
370360
$user->password_hash = $passwords->hash($givenPassword);
371361
$this->provider->save($user);
372362
}

src/Authentication/Passwords.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,6 @@ public function verify(string $password, string $hash): bool
9090
return password_verify($password, $hash);
9191
}
9292

93-
/**
94-
* Verifies a password against a previously hashed password.
95-
*
96-
* @param string $password The password we're checking
97-
* @param string $hash The previously hashed password
98-
*
99-
* @deprecated This is only for backward compatibility.
100-
*/
101-
public function verifyDanger(string $password, string $hash): bool
102-
{
103-
return password_verify(base64_encode(
104-
hash('sha384', $password, true)
105-
), $hash);
106-
}
107-
10893
/**
10994
* Checks to see if a password should be rehashed.
11095
*/

src/Config/Auth.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,6 @@ class Auth extends BaseConfig
374374
*/
375375
public int $hashCost = 12;
376376

377-
/**
378-
* If you need to support passwords saved in versions prior to Shield v1.0.0-beta.4.
379-
* set this to true.
380-
*
381-
* See https://github.com/codeigniter4/shield/security/advisories/GHSA-c5vj-f36q-p9vg
382-
*
383-
* @deprecated This is only for backward compatibility.
384-
*/
385-
public bool $supportOldDangerousPassword = false;
386-
387377
/**
388378
* ////////////////////////////////////////////////////////////////////
389379
* OTHER SETTINGS

tests/Authentication/Authenticators/SessionAuthenticatorTest.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -313,34 +313,6 @@ public function testCheckSuccess(): void
313313
$this->assertSame($this->user->id, $foundUser->id);
314314
}
315315

316-
public function testCheckSuccessOldDangerousPassword(): void
317-
{
318-
/** @var Auth $config */
319-
$config = config('Auth');
320-
$config->supportOldDangerousPassword = true; // @phpstan-ignore-line
321-
322-
fake(
323-
UserIdentityModel::class,
324-
[
325-
'user_id' => $this->user->id,
326-
'type' => Session::ID_TYPE_EMAIL_PASSWORD,
327-
'secret' => '[email protected]',
328-
'secret2' => '$2y$10$WswjNNcR24cJvsXvBc5TveVVVQ9/EYC0eq.Ad9e/2cVnmeSEYBOEm',
329-
]
330-
);
331-
332-
$result = $this->auth->check([
333-
'email' => '[email protected]',
334-
'password' => 'passw0rd!',
335-
]);
336-
337-
$this->assertInstanceOf(Result::class, $result);
338-
$this->assertTrue($result->isOK());
339-
340-
$foundUser = $result->extraInfo();
341-
$this->assertSame($this->user->id, $foundUser->id);
342-
}
343-
344316
public function testAttemptCannotFindUser(): void
345317
{
346318
$result = $this->auth->attempt([

0 commit comments

Comments
 (0)