spring-security - Postman 应用程序的基本 HTTP 身份验证
问题描述
我无法理解一件特定的事情。我http-basic
在我的服务器上使用身份验证。
我的代码是:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/user/save")
.permitAll()
.and()
.authorizeRequests()
.antMatchers("/user/**")
.hasRole("USER")
.and()
.authorizeRequests()
.antMatchers("/admin/**")
.hasRole("ADMIN")
.and()
.httpBasic()
.and()
.logout()
.permitAll()
.and()
.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
}
我的请求映射/user
是:
@GetMapping
public Principal user(Principal user){
return user;
}
当我在邮递员应用程序/user
中使用用户名和密码查询端点时,我得到了所需的认证结果。
但是,当我使用故意错误的密码更新标头时,我仍然得到经过身份验证的结果。我不明白为什么会这样。
此外,POST
端点上的请求/logout
失败并显示:
{
"timestamp": "2018-07-30T07:42:48.172+0000",
"status": 403,
"error": "Forbidden",
"message": "Forbidden",
"path": "/logout"
}
我无法理解。任何帮助表示赞赏。
解决方案
推荐阅读
- appium-android - Windows 10:appium doctor --android 显示 --android-coverage 期待参数
- xml - XML 文件是否应该符合 XSD 的所有元素?
- css - 如何在滚动框中制作具有固定宽度但相对高度的元素
- php - setcookie() 返回 false。会话也不起作用
- dialogflow-es - 在 Google Home 上播放音乐
- java - 使用maven在里面创建带有xml文件的jar文件
- python - 示例龙卷风网络请求
- java - Java 整数流
- java - 使用 TDD 的 RockPaperScissors 游戏(三局两胜)
- c# - 使用嵌套 if 语句编写 ac# 程序以查找三个数字中的最小者?