Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +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, @vjik)

## 2.3.2 December 23, 2025

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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,
];
```

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Comment thread
klsoft-web marked this conversation as resolved.
"yiisoft/cookies": "^1.2",
"yiisoft/session": "^1.0 || ^2.0 || ^3.0",
"yiisoft/http": "^1.2"
Expand Down
2 changes: 2 additions & 0 deletions config/di-web.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Yiisoft\Auth\AuthenticationMethodInterface;
use Yiisoft\Auth\AuthenticatorInterface;
use Yiisoft\User\CurrentUser;
use Yiisoft\User\Guest\GuestIdentityFactory;
use Yiisoft\User\Guest\GuestIdentityFactoryInterface;
Expand All @@ -27,6 +28,7 @@
'withAuthUrl()' => [$params['yiisoft/user']['authUrl']],
],

AuthenticatorInterface::class => WebAuth::class,
AuthenticationMethodInterface::class => WebAuth::class,
GuestIdentityFactoryInterface::class => GuestIdentityFactory::class,

Expand Down
6 changes: 5 additions & 1 deletion src/Method/ApiAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
use Yiisoft\User\CurrentUser;

/**
* Implementation of the `AuthenticationMethodInterface` 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 AuthenticationMethodInterface
{
Expand Down
6 changes: 5 additions & 1 deletion src/Method/WebAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
use Yiisoft\User\CurrentUser;

/**
* Implementation of the `AuthenticationMethodInterface` for authenticating users in the web applications.
* 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 AuthenticationMethodInterface
{
Expand Down
5 changes: 4 additions & 1 deletion src/UserAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
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.
* See https://github.com/yiisoft/user/issues/131.
*
* @psalm-suppress DeprecatedInterface
*/
final class UserAuth implements AuthenticationMethodInterface
{
Expand Down
9 changes: 7 additions & 2 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Psr\Log\LoggerInterface;
use ReflectionObject;
use Yiisoft\Auth\AuthenticationMethodInterface;
use Yiisoft\Auth\AuthenticatorInterface;
use Yiisoft\Auth\IdentityRepositoryInterface;
use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;
Expand All @@ -37,11 +38,13 @@ 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(AuthenticatorInterface::class);

$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);
Expand All @@ -67,11 +70,13 @@ public function testOverrideParams(): void
],
]);

$webAuth = $container->get(AuthenticationMethodInterface::class);
$webAuth = $container->get(AuthenticatorInterface::class);

$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);
Expand Down
Loading