gpt4 book ai didi

交响乐 3.4 "Refreshing a deauthenticated user is deprecated"

转载 作者:行者123 更新时间:2023-12-02 20:31:53 28 4
gpt4 key购买 nike

在尝试将现有的 symfony 项目从 3.3.10 升级到 3.4.x(应该是 LTS)时,我设法通过 Composer 升级组件。升级后,所有事情都按预期工作,但单元测试显示弃用错误

Refreshing a deauthenticated user is deprecated as of 3.4 and will trigger a logout in 4.0: 77x

一些谷歌搜索让我找到了可能显示更改的提交 https://github.com/showpad/Symfony-Security/pull/1/commits/3663bbec5fc60565de476fc180f85e1121339072

所以我尝试解决它,在深入研究代码后,我将新设置放入 security.xml

         main:
+ logout_on_user_change: true
anonymous: ~

这解决了弃用警告,但完全破坏了使用自定义实体的身份验证,用户根本没有经过身份验证并且日志显示错误:

[2017-12-07 15:48:24] security.DEBUG: Token was deauthenticated after trying to refresh it. {"username":"aaa","provider":"Symfony\\Bridge\\Doctrine\\Security\\User\\EntityUserProvider"} []

所以问题是“如何正确解决弃用问题”?

最佳答案

认证失效的问题
2017-12-07 15:48:24] security.DEBUG: token 在尝试刷新后被取消验证。 {"username":"aaa","provider":"Symfony\\Bridge\\Doctrine\\Security\\User\\EntityUserProvider"} []

是,我没有遵循文档 https://symfony.com/doc/3.4/security/entity_provider.html#create-your-user-entity这表示,还应该有密码字段(我不会让 symfony 将凭据放在磁盘上太多次)。在 symfony 3.3 中没问题,在 symfony 3.4 中该字段必须存在...

diff --git a/src/GuserBundle/Entity/User.php b/src/GuserBundle/Entity/User.php
index 4adeaf9..b1b33fd 100644
--- a/src/GuserBundle/Entity/User.php
+++ b/src/GuserBundle/Entity/User.php
@@ -152,13 +152,13 @@ class User implements AdvancedUserInterface, \Serializable {
/** @see \Serializable::serialize() */
public function serialize() {
- return serialize(array($this->id, $this->username, $this->active,));
+ return serialize(array($this->id, $this->username, $this->password, $this->active, $this->locked));
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized) {
- list($this->id, $this->username, $this->active,) = unserialize($serialized);
+ list($this->id, $this->username, $this->password, $this->active, $this->locked) = unserialize($serialized);
}

关于交响乐 3.4 "Refreshing a deauthenticated user is deprecated",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47698006/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com