Dav*_*dda 4 spring-security url-mapping
我有一个rest webservice配置为spring boot应用程序.我所有的其他网址都有一个基本路径"/ api/...".我也在为我的应用程序提供静态内容.我只需要为Web服务配置安全性,即以"/ api/..."开头的URL,但是给其他静态内容不应用安全性.
我只看到了通过以下方式过滤一些网址模式的示例:
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/resources/*");
}
Run Code Online (Sandbox Code Playgroud)
但不是......
使用类的antMatcher方法HttpSecurity:
@Configuration
@EnableWebSecurity
public class MySecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/api/**");
// add security constraints for /api/... here
}
/* rest of config */
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17591 次 |
| 最近记录: |