【发布时间】:2019-12-13 01:32:04
【问题描述】:
我创建了 Angular JS 项目,该项目在节点服务器中的 4200 端口下运行,并且基于 Spring Boot 的 REST 数据服务作为单独的项目在 Eclipse 中在 8080 端口下运行。 REST 服务 (RS) 部分使用基于 OAuth 的安全性并验证每个 access_token 请求。这作为单独的实体完全可以正常工作。
现在,我尝试在 WAR 的根文件夹中构建带有角度编译输出的单个 WAR,如果我访问应用程序(通过访问任何 URL) - 在 Angular NG-router Spring 启动安全出现之前并拒绝没有 OAuth 的请求验证。
@Override
public void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**").authorizeRequests().antMatchers("/error").permitAll().anyRequest().authenticated();
http.csrf().disable();
http.headers().frameOptions().disable();
http.cors().configurationSource(new CorsConfigurationSource() {
@Override
public CorsConfiguration getCorsConfiguration(HttpServletRequest request) {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedHeaders(Collections.singletonList("*"));
config.setAllowedMethods(Collections.singletonList("*"));
config.addAllowedOrigin("*");
config.setAllowCredentials(true);
return config;
}
});
}
这是我的安全配置文件。请告知是否将两个单独的 WAR 放入单个模块 EAR 中是否可以解决此问题。
【问题讨论】:
标签: java spring spring-boot spring-security spring-oauth2