2015-02-23 88 views
2

我有一个Spring Boot应用程序,提供安全的Restful Web服务。它的工作原理以及与它自己的WebSecurityConfigurerAdapter级以下HttpSecurity配置:为授权和非授权的宁静服务配置Spring安全

@Override 
protected void configure(HttpSecurity http) throws Exception { 
    http.csrf().disable(); 
    http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); 
    http.authorizeRequests() 
     .antMatchers("/secure/**").hasRole(ROLE_XXX) 
     .anyRequest().authenticated().and().httpBasic(); 
} 

此配置强制所有的web服务,以/secure下授权。 现在我想添加另一个webservice,比如/public/test,这可以在没有任何验证的情况下调用。有什么建议么 ?

回答

0

重写void configure(WebSecurity web)方法解决我的问题:

@Override 
public void configure(WebSecurity web) throws Exception { 
web.ignoring().antMatchers("/public/**"); 
}