gpt4 book ai didi

java - 在 Spring Security 中实现 UserDetails 和 CredentialsContainer

转载 作者:行者123 更新时间:2023-11-30 08:01:01 25 4
gpt4 key购买 nike

我想在登录后删除用户的凭据,因此我在我的 Account 类中实现 UserDetails 和 CredentialsContainer。

@Entity
public class Account implements UserDetails, CredentialsContainer {
...

但是,在文档中它说 CredentialsContainer 仅供内部框架使用

所以我想知道这是否会成为 future 的问题。

最佳答案

您可以实现该接口(interface)。但是,如果您正在编写自己的 AuthenticationProvider,则不打算实现它。来自javadoc:

For internal framework use only. Users who are writing their own AuthenticationProvider implementations should create and return an appropriate Authentication object there, minus any sensitive data, rather than using this interface.

因此,您可以实现它,以便 Spring Security 将在您的应用程序上调用eraseCredentials。但是,不建议您在CredentialsContainer上调用eraseCredentials。

关于java - 在 Spring Security 中实现 UserDetails 和 CredentialsContainer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31921460/

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