【发布时间】:2017-08-07 17:22:55
【问题描述】:
目前我在使用 Spring Security 和连接的 Angular 时遇到了一些问题。我在一个类中配置了 Spring Security,如下所示:
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers(HttpMethod.OPTIONS, "/**")
.antMatchers("/app/**/*.{js,html}")
.antMatchers("/static/node_modules/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/auth").permitAll()
.antMatchers("/", "/login").permitAll()
.antMatchers("/resources/templates/index.html").permitAll()
.antMatchers("/api/client, /api/reservation", "/api/reservationreminder", "/api/review", "/api/user", "/api/vehicle", "/api/wash", "/api/washlocation", "/api/washtype", "/api/worker").hasAuthority(AuthoritiesConstants.CLIENT)
.antMatchers("/static/app/styles", "/static/app/js").permitAll()
.anyRequest().authenticated()
.and()
.logout()
.logoutSuccessUrl("/static/views/pages/login.html")
.permitAll()
.and()
.formLogin()
.loginProcessingUrl("/static/views/pages/login.html")
.permitAll()
}
每次我尝试运行我的应用程序时,我都会在浏览器中失败:
但是当我扔掉.anyRequest().authenticated() 时,一切似乎都正常了——这样我就可以在浏览器中看到我的应用程序了。在该示例中不起作用的事情是 Spring Security 不起作用 - 我的意思是尽管我每个站点都有角色,但我可以从角色/用户访问这些站点,理论上我不能......
【问题讨论】:
标签: angularjs spring spring-boot spring-security