且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

令牌在尝试刷新后被取消身份验证

更新时间:2023-12-01 13:20:16

从 Symfony 4.0 开始,logout_on_user_change 设置为 true.这意味着如果用户被更改,用户将被注销.

As of Symfony 4.0, logout_on_user_change is set to true. That means a user will be logged out if it has been changed.

你应该实现 SymfonyComponentSecurityCoreUserEquatableInterface 并添加 isEqualTo 方法:

You should implement SymfonyComponentSecurityCoreUserEquatableInterface and add the isEqualTo method:

class User implements EquatableInterface
{
    public function isEqualTo(UserInterface $user)
    {
        if ($this->password !== $user->getPassword()) {
            return false;
        }

        if ($this->salt !== $user->getSalt()) {
            return false;
        }

        if ($this->username !== $user->getUsername()) {
            return false;
        }

        return true;
    }
}

更新日志

https://github.com/symfony/security-bundle/blob/master/CHANGELOG.md

4.1.0

logout_on_user_change 防火墙选项已弃用,将在 5.0 中删除.

The logout_on_user_change firewall option is deprecated and will be removed in 5.0.

4.0.0

防火墙选项 logout_on_user_change 现在始终为 true,如果用户在请求之间发生更改,它将触发注销

the firewall option logout_on_user_change is now always true, which will trigger a logout if the user changes between requests

3.4.0

在防火墙选项中添加了logout_on_user_change.当用户更改时,此配置项将触发注销.应设置为 true 以避免配置中的弃用.

Added logout_on_user_change to the firewall options. This config item will trigger a logout when the user has changed. Should be set to true to avoid deprecations in the configuration.

在撰写此答案时尚未记录该选项:https://github.com/symfony/symfony-docs/issues/8428,但现在是:https://symfony.com/doc/4.4/reference/configuration/security.html#logout-on-user-change

The option wasn't documented by the time of writing this answer: https://github.com/symfony/symfony-docs/issues/8428, but it now is: https://symfony.com/doc/4.4/reference/configuration/security.html#logout-on-user-change

如果要升级到新的主要版本,请始终先更新到最新的次要版本.这意味着先更新到 2.8,然后再更新到 3.0,再更新到 3.4,然后再到 4.0.请参阅 Fabien Potencier 的 Symfony 4:撰写您的应用程序.

If you want to upgrade to a new major version, always update to the latest minor version first. That means update to 2.8 before updating to 3.0 and updating to 3.4 before going to 4.0. See Symfony 4: Compose your Applications by Fabien Potencier.

Symfony 3.0 = Symfony 2.8 - 不推荐使用的功能

Symfony 3.0 = Symfony 2.8 - deprecated features

(..)

Symfony 4.0 = Symfony 3.4 - 不推荐使用的功能 + 一种新的开发方式应用程序

Symfony 4.0 = Symfony 3.4 - deprecated features + a new way to develop applications

如果您已经在使用最新的次要版本,更新到新的主要版本会容易得多,因为您可以看到所有弃用通知.

Updating to a new major release is much easier if you're already on the latest minor release, because you can see all deprecation notices.