【发布时间】:2016-12-06 23:59:52
【问题描述】:
我正在使用 Angular 和 Spring Boot 来构建一个带有 Rest API 的单页应用程序。这是我的配置:
@SpringBootApplication
@EnableOAuth2Sso
public class AppConfig extends SpringBootServletInitializer implements ApplicationContextAware {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(AppConfig.class);
}
public static void main(String[] args) {
ApplicationContext appContext = SpringApplication.run(AppConfig.class);
context = appContext;
}
@Configuration
protected static class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/healthcheck", "/").permitAll()
.antMatchers("/api/**").authenticated()
.anyRequest().authenticated();
}
}
}
我使用的 SSO 服务由 Pivotal Cloud Foundry[PCF] 提供。在我加入之前一切都很好
安全配置
类。加载应用程序后,用户将立即重定向到 SSO 登录页面,然后重定向回应用程序。但我需要从身份验证中排除“健康检查”URL。这就是我包含 SecurityConfig 类的原因。但是现在 SSO 身份验证根本不起作用。我只能到达 /healthcheck。
我按照这个例子https://spring.io/guides/tutorials/spring-boot-oauth2/
有人可以告诉我我的代码有什么问题吗?
谢谢。
【问题讨论】:
标签: spring-boot spring-security single-sign-on cloud-foundry