【发布时间】:2021-04-21 04:22:58
【问题描述】:
我从 Spring-Boot 开始,并有一个带有 WebSecurity 的应用程序。 它工作正常,我有静态用户/密码的 InMemory 身份验证。
现在我不需要 DB 或 LDAP 或 ...
@Override
public void configure (AuthenticationManagerBuilder auth) throws Exception
{
auth.inMemoryAuthentication ()
.withUser ("sam").
.password (passwordEncoder ().encode ("secret"))
.authorities ("ROLE_USER");
}
但我想构建一个使用动态数据的自定义身份验证器(例如,密码中包含当前时间)。
如何实现自定义身份验证器?如何查看用户名和密码并进行检查?
感谢您的帮助!
【问题讨论】:
-
我建议您阅读有关 FormLogin 的工作原理docs.spring.io/spring-security/site/docs/current/reference/…
标签: java spring spring-boot spring-security