基地URI春季启动安全
问题描述:
在老春(春季启动前)我在web.xml基地URI春季启动安全
<filter-mapping>
<filter-name>myFilter</filter-name>
<url-pattern>/rest/*</url-pattern>
</filter-mapping>
并以这种方式安全性只加到下定义的URI“/ REST /”,并担任静态资源从根目录不受保护(我的html/Angular2内容)。但是我找不到在Spring Boot中做同样的参考,有没有人已经解决了这个问题?
答
从您的web.xml中我找不到任何安全配置。
但是正如你所描述的那样,你可以通过像下面这样的弹簧安全来配置它,以允许“/”但是需要对“/ rest /”路径进行身份验证。
@Configuration
@EnableGlobalAuthentication
public class ResourceSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/rest/**").authenticated()
......
}
}
这是一个很好的https://spring.io/guides/tutorials/spring-security-and-angular-js/教程系列为此。