java - 如何使 Spring Security 对每个包含单词 admin 的 URL 都有效?
问题描述
.antMatchers("**/admin/**").authenticated()
显然上面的代码不起作用
解决方案
可以参考:https ://www.baeldung.com/spring-security-basic-authentication
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/securityNone").permitAll()
.anyRequest().authenticated()
.and()
.httpBasic()
.authenticationEntryPoint(authenticationEntryPoint);
http.addFilterAfter(new CustomFilter(),
BasicAuthenticationFilter.class);
}
PermitAll 应该可以解决您的问题。
推荐阅读
- ios - 如何将触摸从 UIScrollView 移动到 UITableViewCell?
- python - 关于 tf.layers.batch_normalization 的问题
- android - 如何根据每个片段更改 CollapsingToolbarLayout 中的图像视图?
- java - 如何在 LibGDX 中的按钮上切换“过度”样式?
- mongodb - 如何在 upsert 上添加到数组
- javascript - 处理具有相同ajax调用的多个按钮
- sql - SQL 查询从以下字符串中检索 2 位数字
- docker - Spark Standalone 不适用于本地文件系统
- c# - 如何在 ASP.NET MVC CORE 中使用特殊属性绑定模型
- javascript - 如何使用 JSON 格式获取同一节点级别的键值