使用 spring 安全恢复用户名和密码

Recover username and password with spring security

我在我的网络应用程序中使用 spring 安全性。 我正处于恢复 usernamepassword.

的阶段

用例:

当用户忘记他们的密码时,他们将无法登录。
如何通过spring安全?

spring发送请求

问题是 spring security 不会让任何东西通过,除非 logged in 已验证.

我目前在我的配置中使用以下内容:

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers("/loginrecover/**"); 
}

我认为这完全超出了安全范围并且很容易受到攻击。

还有其他方法可以实现吗?

我会用:

    @Override
    protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().antMatchers("/loginrecover").permitAll()
...}

使用 permitAll,您不会禁用安全过滤器。 Spring 与安全相关的功能仍然可用。

使用 ignoring() 可以完全禁用该请求路径的安全过滤器链。 Spring 安全功能将不可用。这是 java 安全配置 "none"。 这应该只针对静态资源

是的,它很相似,您需要一个未经授权的网站。但正确的方法是只禁用访问而不是过滤器。