401 关于 Spring 引导和 Spring 安全性的 URL 身份验证



我正在使用带有Spring安全性的Springboot。在以下配置下,

http.csrf()
    .disable().authorizeRequests()
    .antMatchers(HttpMethod.POST, "/myHome").authenticated();

我可以通过在 POSTMAN 中添加基本身份验证标头来访问我的主页。

但是访问 with URL 会给出 401。

http://testUser:testPassword@localhost:8080/myHome

我错过了什么吗?

Spring Security的基本身份验证要求username:password标头中的Base64编码字符串。

Base64.encode("username:password");

使用http://user:password@domain/并不安全。

最新更新