我想允许每个人访问/但限制所有其他路径
类似于
.antMatchers("/").permitAll()
.antMatchers("NOT /").authenticated()
我如何设置“NOT/”的模式?
最佳答案
试试这个:
.antMatchers("/").permitAll()
.anyRequest().authenticated()
permitAll()
只会应用于匹配 "/"
的请求,其他请求将进一步路由到 authenticated()
。
关于java - Spring Security 允许 root 的所有内容,但保护其他所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61609004/