From 0c7e094b37a573a06b01b60b80aabd346dd81f64 Mon Sep 17 00:00:00 2001 From: klsoft-web Date: Fri, 21 Aug 2026 20:48:21 +0300 Subject: [PATCH 1/9] Fix deprecated classes usage --- CHANGELOG.md | 1 + composer.json | 2 +- src/Method/ApiAuth.php | 18 +++++--------- src/Method/WebAuth.php | 18 +++++--------- src/UserAuth.php | 15 ++++-------- src/UserAuthenticator.php | 26 ++++++++++++++++++++ tests/UserAuthenticatorTest.php | 42 +++++++++++++++++++++++++++++++++ 7 files changed, 86 insertions(+), 36 deletions(-) create mode 100644 src/UserAuthenticator.php create mode 100644 tests/UserAuthenticatorTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index b016b76..bdc2a1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 2.3.3 under development - Enh #120: Explicitly import classes and constants in "use" section (@vjik) +- Enh #127: Fix deprecated classes usage (@klsoft-web) ## 2.3.2 December 23, 2025 diff --git a/composer.json b/composer.json index 2345ad2..830a9dc 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "psr/http-server-middleware": "^1.0", "psr/log": "^1.1 || ^2.0 || ^3.0", "yiisoft/access": "^2.0", - "yiisoft/auth": "^2.0 || ^3.0", + "yiisoft/auth": "^3.3.0", "yiisoft/cookies": "^1.2", "yiisoft/session": "^1.0 || ^2.0 || ^3.0", "yiisoft/http": "^1.2" diff --git a/src/Method/ApiAuth.php b/src/Method/ApiAuth.php index e43fe8a..44a6982 100644 --- a/src/Method/ApiAuth.php +++ b/src/Method/ApiAuth.php @@ -6,24 +6,18 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Auth\AuthenticationMethodInterface; +use Yiisoft\Auth\AuthenticatorWithChallengeInterface; use Yiisoft\Auth\IdentityInterface; use Yiisoft\User\CurrentUser; +use Yiisoft\User\UserAuthenticator; /** - * Implementation of the `AuthenticationMethodInterface` for authenticating users in the API clients. + * Implementation of the `AuthenticatorWithChallengeInterface` for authenticating users in the API clients. */ -final class ApiAuth implements AuthenticationMethodInterface +final class ApiAuth extends UserAuthenticator implements AuthenticatorWithChallengeInterface { - public function __construct(private readonly CurrentUser $currentUser) {} - - public function authenticate(ServerRequestInterface $request): ?IdentityInterface - { - if ($this->currentUser->isGuest()) { - return null; - } - - return $this->currentUser->getIdentity(); + public function __construct(private readonly CurrentUser $currentUser) { + parent::__construct($this->currentUser); } public function challenge(ResponseInterface $response): ResponseInterface diff --git a/src/Method/WebAuth.php b/src/Method/WebAuth.php index 90097b6..ff2f492 100644 --- a/src/Method/WebAuth.php +++ b/src/Method/WebAuth.php @@ -7,30 +7,24 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Auth\AuthenticationMethodInterface; +use Yiisoft\Auth\AuthenticatorWithChallengeInterface; use Yiisoft\Auth\IdentityInterface; use Yiisoft\Http\Status; use Yiisoft\User\CurrentUser; +use Yiisoft\User\UserAuthenticator; /** - * Implementation of the `AuthenticationMethodInterface` for authenticating users in the web applications. + * Implementation of the `AuthenticatorWithChallengeInterface` for authenticating users in the web applications. */ -final class WebAuth implements AuthenticationMethodInterface +final class WebAuth extends UserAuthenticator implements AuthenticatorWithChallengeInterface { private string $authUrl = '/login'; public function __construct( private readonly CurrentUser $currentUser, private readonly ResponseFactoryInterface $responseFactory, - ) {} - - public function authenticate(ServerRequestInterface $request): ?IdentityInterface - { - if ($this->currentUser->isGuest()) { - return null; - } - - return $this->currentUser->getIdentity(); + ) { + parent::__construct($this->currentUser); } /** diff --git a/src/UserAuth.php b/src/UserAuth.php index a473a4b..aba0b45 100644 --- a/src/UserAuth.php +++ b/src/UserAuth.php @@ -7,7 +7,7 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Auth\AuthenticationMethodInterface; +use Yiisoft\Auth\AuthenticatorWithChallengeInterface; use Yiisoft\Auth\IdentityInterface; use Yiisoft\Http\Status; use Yiisoft\User\Method\WebAuth; @@ -17,19 +17,12 @@ * * @deprecated Use {@see WebAuth}. This class will be removed in the next major version. */ -final class UserAuth implements AuthenticationMethodInterface +final class UserAuth extends UserAuthenticator implements AuthenticatorWithChallengeInterface { private string $authUrl = '/login'; - public function __construct(private CurrentUser $currentUser, private ResponseFactoryInterface $responseFactory) {} - - public function authenticate(ServerRequestInterface $request): ?IdentityInterface - { - if ($this->currentUser->isGuest()) { - return null; - } - - return $this->currentUser->getIdentity(); + public function __construct(private CurrentUser $currentUser, private ResponseFactoryInterface $responseFactory) { + parent::__construct($this->currentUser); } /** diff --git a/src/UserAuthenticator.php b/src/UserAuthenticator.php new file mode 100644 index 0000000..c3b221a --- /dev/null +++ b/src/UserAuthenticator.php @@ -0,0 +1,26 @@ +currentUser->isGuest()) { + return null; + } + + return $this->currentUser->getIdentity(); + } +} diff --git a/tests/UserAuthenticatorTest.php b/tests/UserAuthenticatorTest.php new file mode 100644 index 0000000..4d023c3 --- /dev/null +++ b/tests/UserAuthenticatorTest.php @@ -0,0 +1,42 @@ +createCurrentUser(); + $user->login(new MockIdentity('test-id')); + $result = (new UserAuthenticator($user))->authenticate(new ServerRequest()); + + $this->assertNotNull($result); + $this->assertSame('test-id', $result->getId()); + } + + public function testIdentityNotAuthenticated(): void + { + $user = $this->createCurrentUser(); + $result = (new UserAuthenticator($user))->authenticate(new ServerRequest()); + + $this->assertNull($result); + } + + + private function createCurrentUser(): CurrentUser + { + return (new CurrentUser(new MockIdentityRepository(), new SimpleEventDispatcher())) + ->withSession(new MockArraySessionStorage()); + } +} From c64cd4d47ba04340b19d2c9a2a8256bdabb5893b Mon Sep 17 00:00:00 2001 From: klsoft-web Date: Mon, 24 Aug 2026 08:26:37 +0300 Subject: [PATCH 2/9] In UserAuth.php, ApiAuth.php and WebAuth.php, the CurrentUser is taken as a plain parameter and the WebAuth bindings in the config/di-web.php file are set to the AuthenticatorWithChallengeInterface --- README.md | 2 +- config/di-web.php | 4 ++-- src/Method/ApiAuth.php | 6 ++---- src/Method/WebAuth.php | 6 ++---- src/UserAuth.php | 6 ++---- tests/ConfigTest.php | 6 +++--- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4ec205f..d2aed31 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ the state at every request. For this purpose, you can use the `clear()` method. ### Authentication methods -This package provides two authentication methods, `WebAuth` and `ApiAuth`, that implement the `Yiisoft\Auth\AuthenticationMethodInterface`. Both can be provided to the `Yiisoft\Auth\Authentication` middleware as authentication method. +This package provides two authentication methods, `WebAuth` and `ApiAuth`, that implement the `Yiisoft\Auth\AuthenticatorWithChallengeInterface`. Both can be provided to the `Yiisoft\Auth\Authentication` middleware as authentication method. #### WebAuth diff --git a/config/di-web.php b/config/di-web.php index 057704a..4dea120 100644 --- a/config/di-web.php +++ b/config/di-web.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Yiisoft\Auth\AuthenticationMethodInterface; +use Yiisoft\Auth\AuthenticatorWithChallengeInterface; use Yiisoft\User\CurrentUser; use Yiisoft\User\Guest\GuestIdentityFactory; use Yiisoft\User\Guest\GuestIdentityFactoryInterface; @@ -27,7 +27,7 @@ 'withAuthUrl()' => [$params['yiisoft/user']['authUrl']], ], - AuthenticationMethodInterface::class => WebAuth::class, + AuthenticatorWithChallengeInterface::class => WebAuth::class, GuestIdentityFactoryInterface::class => GuestIdentityFactory::class, CookieLoginMiddleware::class => [ diff --git a/src/Method/ApiAuth.php b/src/Method/ApiAuth.php index 44a6982..98ef21c 100644 --- a/src/Method/ApiAuth.php +++ b/src/Method/ApiAuth.php @@ -5,9 +5,7 @@ namespace Yiisoft\User\Method; use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; use Yiisoft\Auth\AuthenticatorWithChallengeInterface; -use Yiisoft\Auth\IdentityInterface; use Yiisoft\User\CurrentUser; use Yiisoft\User\UserAuthenticator; @@ -16,8 +14,8 @@ */ final class ApiAuth extends UserAuthenticator implements AuthenticatorWithChallengeInterface { - public function __construct(private readonly CurrentUser $currentUser) { - parent::__construct($this->currentUser); + public function __construct(CurrentUser $currentUser) { + parent::__construct($currentUser); } public function challenge(ResponseInterface $response): ResponseInterface diff --git a/src/Method/WebAuth.php b/src/Method/WebAuth.php index ff2f492..cb452bb 100644 --- a/src/Method/WebAuth.php +++ b/src/Method/WebAuth.php @@ -6,9 +6,7 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; use Yiisoft\Auth\AuthenticatorWithChallengeInterface; -use Yiisoft\Auth\IdentityInterface; use Yiisoft\Http\Status; use Yiisoft\User\CurrentUser; use Yiisoft\User\UserAuthenticator; @@ -21,10 +19,10 @@ final class WebAuth extends UserAuthenticator implements AuthenticatorWithChalle private string $authUrl = '/login'; public function __construct( - private readonly CurrentUser $currentUser, + CurrentUser $currentUser, private readonly ResponseFactoryInterface $responseFactory, ) { - parent::__construct($this->currentUser); + parent::__construct($currentUser); } /** diff --git a/src/UserAuth.php b/src/UserAuth.php index aba0b45..e5e1292 100644 --- a/src/UserAuth.php +++ b/src/UserAuth.php @@ -6,9 +6,7 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; use Yiisoft\Auth\AuthenticatorWithChallengeInterface; -use Yiisoft\Auth\IdentityInterface; use Yiisoft\Http\Status; use Yiisoft\User\Method\WebAuth; @@ -21,8 +19,8 @@ final class UserAuth extends UserAuthenticator implements AuthenticatorWithChall { private string $authUrl = '/login'; - public function __construct(private CurrentUser $currentUser, private ResponseFactoryInterface $responseFactory) { - parent::__construct($this->currentUser); + public function __construct(CurrentUser $currentUser, private ResponseFactoryInterface $responseFactory) { + parent::__construct($currentUser); } /** diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index ecfe8ef..cc62185 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -10,7 +10,7 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Log\LoggerInterface; use ReflectionObject; -use Yiisoft\Auth\AuthenticationMethodInterface; +use Yiisoft\Auth\AuthenticatorWithChallengeInterface; use Yiisoft\Auth\IdentityRepositoryInterface; use Yiisoft\Di\Container; use Yiisoft\Di\ContainerConfig; @@ -37,7 +37,7 @@ public function testBase(): void $this->assertInstanceOf(GuestIdentityFactory::class, $container->get(GuestIdentityFactoryInterface::class)); $this->assertInstanceOf(LoginMiddleware::class, $container->get(LoginMiddleware::class)); - $webAuth = $container->get(AuthenticationMethodInterface::class); + $webAuth = $container->get(AuthenticatorWithChallengeInterface::class); $this->assertInstanceOf(WebAuth::class, $webAuth); $this->assertSame('/login', $this->getInaccessibleProperty($webAuth, 'authUrl')); @@ -67,7 +67,7 @@ public function testOverrideParams(): void ], ]); - $webAuth = $container->get(AuthenticationMethodInterface::class); + $webAuth = $container->get(AuthenticatorWithChallengeInterface::class); $this->assertInstanceOf(WebAuth::class, $webAuth); $this->assertSame('/override', $this->getInaccessibleProperty($webAuth, 'authUrl')); From a1305cc38cc57a27116e79b9d9df748de22a5c01 Mon Sep 17 00:00:00 2001 From: klsoft-web Date: Mon, 24 Aug 2026 12:55:55 +0300 Subject: [PATCH 3/9] The WebAuth bindings in the config/di-web.php file are set to the AuthenticatorInterface --- CHANGELOG.md | 2 +- config/di-web.php | 4 ++-- tests/ConfigTest.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdc2a1a..2dac1c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 2.3.3 under development - Enh #120: Explicitly import classes and constants in "use" section (@vjik) -- Enh #127: Fix deprecated classes usage (@klsoft-web) +- Enh #127: Bump `yiisoft/auth` version to `^3.3.0`, and fix deprecated classes usage (@klsoft-web) ## 2.3.2 December 23, 2025 diff --git a/config/di-web.php b/config/di-web.php index 4dea120..d1e2bc4 100644 --- a/config/di-web.php +++ b/config/di-web.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Yiisoft\Auth\AuthenticatorWithChallengeInterface; +use Yiisoft\Auth\AuthenticatorInterface; use Yiisoft\User\CurrentUser; use Yiisoft\User\Guest\GuestIdentityFactory; use Yiisoft\User\Guest\GuestIdentityFactoryInterface; @@ -27,7 +27,7 @@ 'withAuthUrl()' => [$params['yiisoft/user']['authUrl']], ], - AuthenticatorWithChallengeInterface::class => WebAuth::class, + AuthenticatorInterface::class => WebAuth::class, GuestIdentityFactoryInterface::class => GuestIdentityFactory::class, CookieLoginMiddleware::class => [ diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index cc62185..65469a5 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -10,7 +10,7 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Log\LoggerInterface; use ReflectionObject; -use Yiisoft\Auth\AuthenticatorWithChallengeInterface; +use Yiisoft\Auth\AuthenticatorInterface; use Yiisoft\Auth\IdentityRepositoryInterface; use Yiisoft\Di\Container; use Yiisoft\Di\ContainerConfig; @@ -37,7 +37,7 @@ public function testBase(): void $this->assertInstanceOf(GuestIdentityFactory::class, $container->get(GuestIdentityFactoryInterface::class)); $this->assertInstanceOf(LoginMiddleware::class, $container->get(LoginMiddleware::class)); - $webAuth = $container->get(AuthenticatorWithChallengeInterface::class); + $webAuth = $container->get(AuthenticatorInterface::class); $this->assertInstanceOf(WebAuth::class, $webAuth); $this->assertSame('/login', $this->getInaccessibleProperty($webAuth, 'authUrl')); @@ -67,7 +67,7 @@ public function testOverrideParams(): void ], ]); - $webAuth = $container->get(AuthenticatorWithChallengeInterface::class); + $webAuth = $container->get(AuthenticatorInterface::class); $this->assertInstanceOf(WebAuth::class, $webAuth); $this->assertSame('/override', $this->getInaccessibleProperty($webAuth, 'authUrl')); From 43aaec12d484be80a0017073db4c38d7ec0736d5 Mon Sep 17 00:00:00 2001 From: klsoft-web Date: Mon, 24 Aug 2026 18:04:21 +0300 Subject: [PATCH 4/9] The UserAuthenticator has been removed --- src/Method/ApiAuth.php | 16 +++++++++---- src/Method/WebAuth.php | 18 ++++++++++---- src/UserAuth.php | 17 +++++++++---- src/UserAuthenticator.php | 26 -------------------- tests/UserAuthenticatorTest.php | 42 --------------------------------- 5 files changed, 38 insertions(+), 81 deletions(-) delete mode 100644 src/UserAuthenticator.php delete mode 100644 tests/UserAuthenticatorTest.php diff --git a/src/Method/ApiAuth.php b/src/Method/ApiAuth.php index 98ef21c..fe7bbf6 100644 --- a/src/Method/ApiAuth.php +++ b/src/Method/ApiAuth.php @@ -5,17 +5,25 @@ namespace Yiisoft\User\Method; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; use Yiisoft\Auth\AuthenticatorWithChallengeInterface; +use Yiisoft\Auth\IdentityInterface; use Yiisoft\User\CurrentUser; -use Yiisoft\User\UserAuthenticator; /** * Implementation of the `AuthenticatorWithChallengeInterface` for authenticating users in the API clients. */ -final class ApiAuth extends UserAuthenticator implements AuthenticatorWithChallengeInterface +final class ApiAuth implements AuthenticatorWithChallengeInterface { - public function __construct(CurrentUser $currentUser) { - parent::__construct($currentUser); + public function __construct(private readonly CurrentUser $currentUser) {} + + public function authenticate(ServerRequestInterface $request): ?IdentityInterface + { + if ($this->currentUser->isGuest()) { + return null; + } + + return $this->currentUser->getIdentity(); } public function challenge(ResponseInterface $response): ResponseInterface diff --git a/src/Method/WebAuth.php b/src/Method/WebAuth.php index cb452bb..4bf3224 100644 --- a/src/Method/WebAuth.php +++ b/src/Method/WebAuth.php @@ -6,23 +6,31 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; use Yiisoft\Auth\AuthenticatorWithChallengeInterface; +use Yiisoft\Auth\IdentityInterface; use Yiisoft\Http\Status; use Yiisoft\User\CurrentUser; -use Yiisoft\User\UserAuthenticator; /** * Implementation of the `AuthenticatorWithChallengeInterface` for authenticating users in the web applications. */ -final class WebAuth extends UserAuthenticator implements AuthenticatorWithChallengeInterface +final class WebAuth implements AuthenticatorWithChallengeInterface { private string $authUrl = '/login'; public function __construct( - CurrentUser $currentUser, + private readonly CurrentUser $currentUser, private readonly ResponseFactoryInterface $responseFactory, - ) { - parent::__construct($currentUser); + ) {} + + public function authenticate(ServerRequestInterface $request): ?IdentityInterface + { + if ($this->currentUser->isGuest()) { + return null; + } + + return $this->currentUser->getIdentity(); } /** diff --git a/src/UserAuth.php b/src/UserAuth.php index e5e1292..d5c86e0 100644 --- a/src/UserAuth.php +++ b/src/UserAuth.php @@ -6,21 +6,30 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; use Yiisoft\Auth\AuthenticatorWithChallengeInterface; +use Yiisoft\Auth\IdentityInterface; use Yiisoft\Http\Status; use Yiisoft\User\Method\WebAuth; /** - * Implementation of the authentication interface for the user. + * Implementation of the `AuthenticatorWithChallengeInterface` interface for the user. * * @deprecated Use {@see WebAuth}. This class will be removed in the next major version. */ -final class UserAuth extends UserAuthenticator implements AuthenticatorWithChallengeInterface +final class UserAuth implements AuthenticatorWithChallengeInterface { private string $authUrl = '/login'; - public function __construct(CurrentUser $currentUser, private ResponseFactoryInterface $responseFactory) { - parent::__construct($currentUser); + public function __construct(private CurrentUser $currentUser, private ResponseFactoryInterface $responseFactory) {} + + public function authenticate(ServerRequestInterface $request): ?IdentityInterface + { + if ($this->currentUser->isGuest()) { + return null; + } + + return $this->currentUser->getIdentity(); } /** diff --git a/src/UserAuthenticator.php b/src/UserAuthenticator.php deleted file mode 100644 index c3b221a..0000000 --- a/src/UserAuthenticator.php +++ /dev/null @@ -1,26 +0,0 @@ -currentUser->isGuest()) { - return null; - } - - return $this->currentUser->getIdentity(); - } -} diff --git a/tests/UserAuthenticatorTest.php b/tests/UserAuthenticatorTest.php deleted file mode 100644 index 4d023c3..0000000 --- a/tests/UserAuthenticatorTest.php +++ /dev/null @@ -1,42 +0,0 @@ -createCurrentUser(); - $user->login(new MockIdentity('test-id')); - $result = (new UserAuthenticator($user))->authenticate(new ServerRequest()); - - $this->assertNotNull($result); - $this->assertSame('test-id', $result->getId()); - } - - public function testIdentityNotAuthenticated(): void - { - $user = $this->createCurrentUser(); - $result = (new UserAuthenticator($user))->authenticate(new ServerRequest()); - - $this->assertNull($result); - } - - - private function createCurrentUser(): CurrentUser - { - return (new CurrentUser(new MockIdentityRepository(), new SimpleEventDispatcher())) - ->withSession(new MockArraySessionStorage()); - } -} From b059adfc7e31366b21814308d98fe1ca853cd79c Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 25 Aug 2026 09:57:48 +0300 Subject: [PATCH 5/9] fix bc --- .github/workflows/bc.yml | 1 + .roave-backward-compatibility-check.xml | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 .roave-backward-compatibility-check.xml diff --git a/.github/workflows/bc.yml b/.github/workflows/bc.yml index 3dc34af..fce3582 100644 --- a/.github/workflows/bc.yml +++ b/.github/workflows/bc.yml @@ -5,6 +5,7 @@ on: paths: &paths - 'src/**' - 'config/**' + - '.roave-backward-compatibility-check.xml' - 'composer.json' - '.github/workflows/bc.yml' push: diff --git a/.roave-backward-compatibility-check.xml b/.roave-backward-compatibility-check.xml new file mode 100644 index 0000000..dc75b93 --- /dev/null +++ b/.roave-backward-compatibility-check.xml @@ -0,0 +1,8 @@ + + + + #\[BC\] REMOVED: These ancestors of Yiisoft\\User\\.+ have been removed: \["Yiisoft\\\\Auth\\\\AuthenticationMethodInterface"\]# + + From 3ad46723c938b19da08821d6f9c702e13e7dfdc9 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 25 Aug 2026 10:17:26 +0300 Subject: [PATCH 6/9] fix --- .github/workflows/bc.yml | 1 - .roave-backward-compatibility-check.xml | 8 -------- CHANGELOG.md | 2 +- src/Method/ApiAuth.php | 10 +++++++--- src/Method/WebAuth.php | 8 ++++++-- src/UserAuth.php | 7 +++++-- 6 files changed, 19 insertions(+), 17 deletions(-) delete mode 100644 .roave-backward-compatibility-check.xml diff --git a/.github/workflows/bc.yml b/.github/workflows/bc.yml index fce3582..3dc34af 100644 --- a/.github/workflows/bc.yml +++ b/.github/workflows/bc.yml @@ -5,7 +5,6 @@ on: paths: &paths - 'src/**' - 'config/**' - - '.roave-backward-compatibility-check.xml' - 'composer.json' - '.github/workflows/bc.yml' push: diff --git a/.roave-backward-compatibility-check.xml b/.roave-backward-compatibility-check.xml deleted file mode 100644 index dc75b93..0000000 --- a/.roave-backward-compatibility-check.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - #\[BC\] REMOVED: These ancestors of Yiisoft\\User\\.+ have been removed: \["Yiisoft\\\\Auth\\\\AuthenticationMethodInterface"\]# - - diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dac1c1..bf0dc8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 2.3.3 under development - Enh #120: Explicitly import classes and constants in "use" section (@vjik) -- Enh #127: Bump `yiisoft/auth` version to `^3.3.0`, and fix deprecated classes usage (@klsoft-web) +- Enh #127: Bump `yiisoft/auth` version to `^3.3.0`, and fix deprecated classes usage (@klsoft-web, @vjik) ## 2.3.2 December 23, 2025 diff --git a/src/Method/ApiAuth.php b/src/Method/ApiAuth.php index fe7bbf6..08bd933 100644 --- a/src/Method/ApiAuth.php +++ b/src/Method/ApiAuth.php @@ -6,14 +6,18 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Auth\AuthenticatorWithChallengeInterface; +use Yiisoft\Auth\AuthenticationMethodInterface; use Yiisoft\Auth\IdentityInterface; use Yiisoft\User\CurrentUser; /** - * Implementation of the `AuthenticatorWithChallengeInterface` for authenticating users in the API clients. + * Implementation of the `AuthenticatorInterface` for authenticating users in the API clients. + * + * @psalm-suppress DeprecatedInterface Implements the deprecated `AuthenticationMethodInterface` (instead of + * `AuthenticatorInterface` directly) to avoid a backward compatibility break. Will be switched + * to `AuthenticatorInterface` in the next major version, see https://github.com/yiisoft/user/issues/130. */ -final class ApiAuth implements AuthenticatorWithChallengeInterface +final class ApiAuth implements AuthenticationMethodInterface { public function __construct(private readonly CurrentUser $currentUser) {} diff --git a/src/Method/WebAuth.php b/src/Method/WebAuth.php index 4bf3224..c4c3ced 100644 --- a/src/Method/WebAuth.php +++ b/src/Method/WebAuth.php @@ -7,15 +7,19 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Auth\AuthenticatorWithChallengeInterface; +use Yiisoft\Auth\AuthenticationMethodInterface; use Yiisoft\Auth\IdentityInterface; use Yiisoft\Http\Status; use Yiisoft\User\CurrentUser; /** * Implementation of the `AuthenticatorWithChallengeInterface` for authenticating users in the web applications. + * + * @psalm-suppress DeprecatedInterface Implements the deprecated `AuthenticationMethodInterface` (instead of + * `AuthenticatorWithChallengeInterface` directly) to avoid a backward compatibility break. Will be switched + * to `AuthenticatorWithChallengeInterface` in the next major version, see https://github.com/yiisoft/user/issues/130. */ -final class WebAuth implements AuthenticatorWithChallengeInterface +final class WebAuth implements AuthenticationMethodInterface { private string $authUrl = '/login'; diff --git a/src/UserAuth.php b/src/UserAuth.php index d5c86e0..c05dbb5 100644 --- a/src/UserAuth.php +++ b/src/UserAuth.php @@ -7,7 +7,7 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Yiisoft\Auth\AuthenticatorWithChallengeInterface; +use Yiisoft\Auth\AuthenticationMethodInterface; use Yiisoft\Auth\IdentityInterface; use Yiisoft\Http\Status; use Yiisoft\User\Method\WebAuth; @@ -16,8 +16,11 @@ * Implementation of the `AuthenticatorWithChallengeInterface` interface for the user. * * @deprecated Use {@see WebAuth}. This class will be removed in the next major version. + * See https://github.com/yiisoft/user/issues/131. + * + * @psalm-suppress DeprecatedInterface */ -final class UserAuth implements AuthenticatorWithChallengeInterface +final class UserAuth implements AuthenticationMethodInterface { private string $authUrl = '/login'; From 682a6156972453338884f4f3969fde1e1a733dd0 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 25 Aug 2026 10:19:39 +0300 Subject: [PATCH 7/9] fix --- config/di-web.php | 2 ++ tests/ConfigTest.php | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/config/di-web.php b/config/di-web.php index d1e2bc4..50f1370 100644 --- a/config/di-web.php +++ b/config/di-web.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Yiisoft\Auth\AuthenticationMethodInterface; use Yiisoft\Auth\AuthenticatorInterface; use Yiisoft\User\CurrentUser; use Yiisoft\User\Guest\GuestIdentityFactory; @@ -28,6 +29,7 @@ ], AuthenticatorInterface::class => WebAuth::class, + AuthenticationMethodInterface::class => WebAuth::class, GuestIdentityFactoryInterface::class => GuestIdentityFactory::class, CookieLoginMiddleware::class => [ diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 65469a5..2e6eb5a 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -10,6 +10,7 @@ use Psr\Http\Message\ResponseFactoryInterface; use Psr\Log\LoggerInterface; use ReflectionObject; +use Yiisoft\Auth\AuthenticationMethodInterface; use Yiisoft\Auth\AuthenticatorInterface; use Yiisoft\Auth\IdentityRepositoryInterface; use Yiisoft\Di\Container; @@ -42,6 +43,8 @@ public function testBase(): void $this->assertInstanceOf(WebAuth::class, $webAuth); $this->assertSame('/login', $this->getInaccessibleProperty($webAuth, 'authUrl')); + $this->assertInstanceOf(WebAuth::class, $container->get(AuthenticationMethodInterface::class)); + $cookieLogin = $container->get(CookieLogin::class); $this->assertInstanceOf(CookieLogin::class, $cookieLogin); @@ -72,6 +75,8 @@ public function testOverrideParams(): void $this->assertInstanceOf(WebAuth::class, $webAuth); $this->assertSame('/override', $this->getInaccessibleProperty($webAuth, 'authUrl')); + $this->assertInstanceOf(WebAuth::class, $container->get(AuthenticationMethodInterface::class)); + $cookieLogin = $container->get(CookieLogin::class); $this->assertInstanceOf(CookieLogin::class, $cookieLogin); From dcc34dd486b66721cb739bed68353b3172a2d064 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 25 Aug 2026 10:20:44 +0300 Subject: [PATCH 8/9] fix --- src/Method/ApiAuth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Method/ApiAuth.php b/src/Method/ApiAuth.php index 08bd933..145b080 100644 --- a/src/Method/ApiAuth.php +++ b/src/Method/ApiAuth.php @@ -14,7 +14,7 @@ * Implementation of the `AuthenticatorInterface` for authenticating users in the API clients. * * @psalm-suppress DeprecatedInterface Implements the deprecated `AuthenticationMethodInterface` (instead of - * `AuthenticatorInterface` directly) to avoid a backward compatibility break. Will be switched + * `AuthenticatorInterface` directly) to avoid a backward compatibility break. Will be switched * to `AuthenticatorInterface` in the next major version, see https://github.com/yiisoft/user/issues/130. */ final class ApiAuth implements AuthenticationMethodInterface From 34a55e9d2b3eb03e101ca6f41600a065dac0c96e Mon Sep 17 00:00:00 2001 From: klsoft-web Date: Tue, 25 Aug 2026 17:56:45 +0300 Subject: [PATCH 9/9] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d2aed31..8607d0d 100644 --- a/README.md +++ b/README.md @@ -232,7 +232,7 @@ return [ ``` If the application is used along with the [yiisoft/config](https://github.com/yiisoft/config), the package is [configured](./config/di-web.php) -automatically to use `WebAuth` as default implementation of `Yiisoft\Auth\AuthenticationMethodInterface`. +automatically to use `WebAuth` as default implementation of `Yiisoft\Auth\AuthenticatorInterface`. #### ApiAuth @@ -253,15 +253,15 @@ $middleware = new Authentication( ); ``` -of to define it as an implementation of `Yiisoft\Auth\AuthenticationMethodInterface` in the [DI container](https://github.com/yiisoft/di) configuration: +of to define it as an implementation of `Yiisoft\Auth\AuthenticatorInterface` in the [DI container](https://github.com/yiisoft/di) configuration: ```php // config/web/di/auth.php -use Yiisoft\Auth\AuthenticationMethodInterface; +use Yiisoft\Auth\AuthenticatorInterface; use Yiisoft\User\Method\ApiAuth; return [ - AuthenticationMethodInterface::class => ApiAuth::class, + AuthenticatorInterface::class => ApiAuth::class, ]; ```