目前,我在Spring Security和连接的Angular中遇到了一些问题。我配置的Spring Security中的一类,它看起来像:Spring Security authenticated()不适用于AngularJS
@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不起作用 - 我的意思是尽管我每个站点都有角色,但我可以从角色/用户那里进入这些站点,理论上我不能。
不。我现在删除静态/并失败,如下所示:http://imgur.com/a/zToHH – bielas
检查此[Spring Boot and Angular](https://github.com/spring-guides/)啧 - 弹簧 - 安全和 - 角JS /树/主/碱性)。你不需要那种类型的控制器。 –
好吧..但我有,需要修复它,因为它是现在.. – bielas