在我升级到 spring-boot 1.3 后,我试图切换到 spring 4.2 的原生 Global CORS 支持,但它似乎不适用于 CAS 过滤器进程 url(/login/cas)。
最初,我使用 spring-boot 1.2.7 和 spring 4.2 和 spring-security 4.0.2,并使用自制的基于过滤的 cors 支持。我自己的休息服务或 CAS ST 验证 URL 运行良好。在我升级到 spring-boot 1.3 并带有 spring 和 spring-security 版本之后。它停止工作。经过一番挖掘,通过AddFilterBefore修复了这个问题。因此,基于过滤的 CORS 似乎也适用于 spring-boot 1.3.0 + spring-security-cas。
但是,我想使用本机全局 CORS,但似乎无法识别 CAS ST 验证 URL(/login/cas),尽管其他其余端点都可以。
请帮忙。
设置非常简单。
@Configuration
public class CorsConfiguration {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**");
}
};
}
}
以下是一些流量:
Request URL:http://localhost:9000/login/cas?ticket=ST-1357-15aQrv93jGEUsQpQRF1P-cas01.example.org
Request Method:GET
Status Code:302 Found
Cache-Control:no-cache, no-store, max-age=0, must-revalidate
Content-Length:0
Date:Thu, 19 Nov 2015 09:19:31 GMT
Expires:0
Location:http://localhost:9000/
Pragma:no-cache
Server:Apache-Coyote/1.1
X-Content-Type-Options:nosniff
X-Frame-Options:DENY
X-XSS-Protection:1; mode=block
以下是控制台错误:
XMLHttpRequest cannot load http://localhost:9000/login/cas?ticket=ST-1357-15aQrv93jGEUsQpQRF1P-cas01.example.org. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.