spring - Spring Boot 安全性 - 执行器
问题描述
我正在尝试将我的应用程序配置为始终公开执行器端点,如果将配置设置为需要安全性,则将其应用于我的端点以进行 websocket 连接
就目前而言,我的印象是蚂蚁匹配器按顺序匹配 - 这意味着
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/health", "/actuator", "actuator/health").permitAll();
if (authenticationRequired) {
http.authorizeRequests().antMatchers("/**").authenticated().and().httpBasic();
}
}
上述代码应始终允许执行器端点
然而似乎事实并非如此。请有人帮助描述我的方法有什么问题。
/health
对/actuator
我来说应该由permitAll()
解决方案
我使用以下匹配器修复了这个问题
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/health", "/actuator/**").permitAll();
if (authenticationRequired) {
http.authorizeRequests().antMatchers("/**").authenticated().and().httpBasic();
}
}
我错过了一个领先的/
推荐阅读
- ios - 使用后将每个单独的项目从数组中逐一删除?
- python - 如何根据 pandas 数据框中其他多个列的值添加两个新列?
- html - 汉堡菜单在我点击后没有关闭(引导程序)
- azure-data-explorer - Azure 数据资源管理器表查看器
- r - 将数据结构绘制为R中的树
- microsoft-graph-toolkit - 如何使用 Microsoft 图形工具包通过电子邮件地址获取用户的存在?
- javascript - 我怎样才能获得当前是否?我在这里做了一些代码,但卡在 fetch()
- unity3d - Unity New Tag 或 Layer 并应用于对象,之后无需在检查器中重新选择
- html - 如何使用透视进行这样的悬停?
- python - 我的 python 代码跳过了 txt 文件的第一行?