Spring boot 注销重定向时密钥斗篷CORS问题
我正在使用Keyclope 10.0.2来保护spring boot REST API和前端的Angular 9。 前端由运行在上的spring boot microservice提供服务http://localhost:8080. 在KeyClope端,openid connect客户端web源配置为允许所有源。Spring boot 注销重定向时密钥斗篷CORS问题,spring-boot,keycloak,spring-security-oauth2,Spring Boot,Keycloak,Spring Security Oauth2,我正在使用Keyclope 10.0.2来保护spring boot REST API和前端的Angular 9。 前端由运行在上的spring boot microservice提供服务http://localhost:8080. 在KeyClope端,openid connect客户端web源配置为允许所有源。 Spring引导Spring安全性被配置为使用KeyClope作为oauth2客户端提供程序 spring: security: oauth2: client
Spring引导Spring安全性被配置为使用KeyClope作为oauth2客户端提供程序
spring:
security:
oauth2:
client:
provider:
keycloak:
issuer-uri: https://abc-keycloak.abccloud.com/auth/realms/abc
scope: openid, profile
registration:
keycloak:
client-id: localhost
client-secret: xxxxx
redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
resourceserver:
jwt:
issuer-uri: https://abc-keycloak.abccloud.com/auth/realms/abc
角度前端进行注销API调用http://localhost:8080/logout
并被重定向到
HTTP/1.1 302 Found Location:
https://abc-keycloak.abccloud.com/auth/realms/abc/protocol/openid-connect/logout?id_token_hint=xxxxxx
我在Google Chrome浏览器中发现一个CORS错误
访问位于的XMLHttpRequest
'https://abc-keycloak.abccloud.com/auth/realms/abc/protocol/openid-connect/logout?id_token_hint=xxxxxx&post_logout_redirect_uri=http://localhost:8080'
(从'http://localhost:8080/logout""""来源"
'http://localhost:8080'已被CORS策略阻止:响应
飞行前请求未通过访问控制检查:否
“Access Control Allow Origin”标头出现在请求的服务器上
资源
它不应该是一个API调用(backround中的请求)。整个浏览器应导航至该应用程序注销URL(然后导航至KeyClope注销URL)。前端还应导航至KeyClope注销URL?如果前端是第三方,我无法控制它怎么办?强制重定向没有意义。为什么token_endpoint可以,而end_session one可以?@Toilal很简单,您需要删除IDP域上的cookie-在浏览器中终止SSO会话。令牌端点只是API端点,所以它不需要处理任何cookie。