spring - Spring 安全保护注销 url
问题描述
我在我的项目中使用弹簧安全。我使用 @PreAuthorize 注释配置安全端点。我希望 spring security 保护我在配置文件中指定的注销 URL。
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers(LOGOUT_URL).authenticated()
.anyRequest().permitAll()
.and()
.logout()
.logoutUrl(LOGOUT_URL)
.invalidateHttpSession(true)
.logoutSuccessHandler(logoutSuccessHandler);
}
在这里,我允许任何请求,除了注销。我猜这个配置仅适用于 @RestController 端点。但是如何配置它以禁止未经身份验证的用户使用注销。
解决方案
推荐阅读
- java - 我在 java rmi 多客户端代码中有问题
- python - 关系不存在,但没有迁移来应用 Django
- c# - 如何实现一个 utf8 ReadOnlySpan 的字典
? - continuous-integration - 适用于 Android 和 iOS 的 NativeScript CI
- php - 使用默认密码哈希更新 SQL 密码可防止登录
- python - 从没有纬度/经度变量的 NetCDF 中提取纬度/经度
- python-3.x - pdb事后调试:在异常处理程序中退出后跳转到引发异常
- django - 如何将变量从视图传递给函数
- c++ - WIN 中的相同 DevIL 项目在 Ubuntu 中失败
- regex - 解析 Alexa 以获取排名信息