From 081e9883e6b89432114aff9f828b6875b4d5444b Mon Sep 17 00:00:00 2001 From: Pedro Igor Date: Tue, 4 Sep 2018 16:54:28 -0300 Subject: [PATCH] [KEYCLOAK-7659] - k_version not supporting cors --- .../org/keycloak/adapters/PreAuthActionsHandler.java | 9 +++++++++ .../arquillian/DeploymentArchiveProcessorUtils.java | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/PreAuthActionsHandler.java b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/PreAuthActionsHandler.java index 0e8b825d35..609e0f9aad 100755 --- a/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/PreAuthActionsHandler.java +++ b/adapters/oidc/adapter-core/src/main/java/org/keycloak/adapters/PreAuthActionsHandler.java @@ -249,6 +249,15 @@ public class PreAuthActionsHandler { protected void handleVersion() { try { facade.getResponse().setStatus(200); + KeycloakDeployment deployment = deploymentContext.resolveDeployment(facade); + if (deployment.isCors()) { + String origin = facade.getRequest().getHeader(CorsHeaders.ORIGIN); + if (origin == null) { + log.debug("no origin header set in request"); + } else { + facade.getResponse().setHeader(CorsHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, origin); + } + } facade.getResponse().setHeader("Content-Type", "application/json"); JsonSerialization.writeValueToStream(facade.getResponse().getOutputStream(), VersionRepresentation.SINGLETON); } catch (Exception e) { diff --git a/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/DeploymentArchiveProcessorUtils.java b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/DeploymentArchiveProcessorUtils.java index 328c1f7626..0affad501e 100644 --- a/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/DeploymentArchiveProcessorUtils.java +++ b/testsuite/integration-arquillian/util/src/main/java/org/keycloak/testsuite/utils/arquillian/DeploymentArchiveProcessorUtils.java @@ -231,7 +231,7 @@ public class DeploymentArchiveProcessorUtils { private static String getAuthServerUrl() { String scheme = AUTH_SERVER_SSL_REQUIRED ? "https" : "http"; - String host = System.getProperty("app.server.host", "localhost"); + String host = System.getProperty("auth.server.host", "localhost"); String port = AUTH_SERVER_SSL_REQUIRED ? System.getProperty("auth.server.https.port", "8443") : System.getProperty("auth.server.http.port", "8180");