【发布时间】:2019-04-02 21:14:56
【问题描述】:
我正在使用 Angular 和 Spring Boot 来构建一个带有 Rest API 的单页应用程序。这是我的 SpringBoot 应用程序:
@SpringBootApplication
@Controller
public class AptSsoAppApplication {
public static void main(String[] args) {
if ("true".equals(System.getenv("SKIP_SSL_VALIDATION"))) {
SSLValidationDisabler.disableSSLValidation();
}
SpringApplication.run(AptSsoAppApplication.class, args);
}
@EnableOAuth2Sso
@Configuration
protected static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/health").permitAll()
.anyRequest().authenticated().and()
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
}
}
Angular 项目包含组件。其中一个组件是为健康检查而设计的。 SpringBoot 应该忽略健康组件的 SSO。
我遵循了这个例子:https://spring.io/guides/tutorials/spring-security-and-angular-js/
对于所有 Angular 路由,都显示 SSO 身份验证页面。 有人可以告诉我我的代码有什么问题吗?
【问题讨论】:
-
您是否在 Spring 项目中封装了 Angular 代码?也许在 src/main/resources 或类似的东西下?
-
是的。我将我的角度代码包装在 SpringBoot 项目中。
标签: angular spring-boot single-sign-on spring-security-oauth2 cloud-foundry