首页 > 解决方案 > 使用spring security自定义授权运行一段时间后用户名和密码为空

问题描述

我做了一个自定义授权来检查一些规则的用户名和密码。
起初一切正常,但在服务器运行几天后,无论我发送到服务器,用户名和密码都会变为空。
当我重新启动服务器时问题消失了,但几天后又出现了,我必须再次重新启动服务器。
我不知道哪里出了问题。

我已经在问题之前和之后检查了客户端,但请求很好。

服务器 java

public class LoginProvider implements AuthenticationProvider {
  ...
  public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    String userId = authentication.getName();
    String password = authentication.getCredentials().toString();
    // userId == "", password == ""
    ...
  }
}

客户端javascript

var form = new FormData();
form.append("username", this.username);
form.append("password", this.password);

fetch("/loginApi", {
    method: "POST",
    body: form
})

标签: spring-bootspring-security

解决方案


推荐阅读