[KEYCLOAK-7659] - k_version not supporting cors

This commit is contained in:
Pedro Igor 2018-09-04 16:54:28 -03:00
parent df311b60b4
commit 081e9883e6
2 changed files with 10 additions and 1 deletions

View file

@ -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) {

View file

@ -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");