【发布时间】:2019-04-26 17:20:13
【问题描述】:
我在从 openid connect 注销时遇到以下问题。
"从源访问 '' 处的 XMLHttpRequest(从 '' 重定向) 'http://localhost:8080' 已被 CORS 策略阻止:否 请求中存在“Access-Control-Allow-Origin”标头 资源。”
网络通话显示“已取消”状态。
这里是代码 安全配置.java
@Override
protected void configure(HttpSecurity http) throws Exception {
LOG.info("in configure httpsecurity");
http.csrf().disable().cors().and()
.addFilterAfter(new OAuth2ClientContextFilter(), AbstractPreAuthenticatedProcessingFilter.class)
.addFilterAfter(myFilter(), OAuth2ClientContextFilter.class)
.httpBasic().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint(openIdConfig.getEntrypoint()))
.and()
.authorizeRequests()
.antMatchers(openIdConfig.getEntrypoint()).permitAll()
.anyRequest().authenticated()
.and().logout()//.clearAuthentication(true)
.logoutUrl(openIdConfig.getLogoffURL()+openIdConfig.getRedirectUri()).permitAll()
.invalidateHttpSession(true)
.deleteCookies(OpenIDConstants.SESSION_TOKEN, OpenIDConstants.USERNAME,
OpenIDConstants.JSESSIONID)
.logoutSuccessHandler(logoutSuccessHandler())
.logoutSuccessUrl(openIdConfig.getRedirectUri());
;
LOG.info("in configure httpsecurity end");
// @formatter:on
}
【问题讨论】:
-
这是
cross-origin相关的问题,你需要使用cors中间件在两个不同的服务器之间进行通信 -
你能发布整个安全配置类吗?
标签: spring-boot angular6 spring-security-oauth2