From 1d75b50acb706a81bd4d994ae64d31f1a23a19c3 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Fri, 18 Oct 2013 15:47:33 -0400 Subject: [PATCH] cors --- .../representations/SkeletonKeyToken.java | 15 ++++++++--- .../services/resources/SaasService.java | 27 +++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/keycloak/representations/SkeletonKeyToken.java b/core/src/main/java/org/keycloak/representations/SkeletonKeyToken.java index 3458d707ef..817c9f5b13 100755 --- a/core/src/main/java/org/keycloak/representations/SkeletonKeyToken.java +++ b/core/src/main/java/org/keycloak/representations/SkeletonKeyToken.java @@ -4,10 +4,7 @@ import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonProperty; import org.jboss.resteasy.jwt.JsonWebToken; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Bill Burke @@ -57,6 +54,8 @@ public class SkeletonKeyToken extends JsonWebToken { @JsonProperty("trusted-certs") protected Set trustedCertificates; + @JsonProperty("allowed-origins") + protected List allowsOrigins; @JsonProperty("realm_access") protected Access realmAccess; @@ -144,6 +143,14 @@ public class SkeletonKeyToken extends JsonWebToken { return (SkeletonKeyToken) super.type(type); } + public List getAllowsOrigins() { + return allowsOrigins; + } + + public void setAllowsOrigins(List allowsOrigins) { + this.allowsOrigins = allowsOrigins; + } + public Access getRealmAccess() { return realmAccess; } diff --git a/services/src/main/java/org/keycloak/services/resources/SaasService.java b/services/src/main/java/org/keycloak/services/resources/SaasService.java index b8d2e82b30..38a499124a 100755 --- a/services/src/main/java/org/keycloak/services/resources/SaasService.java +++ b/services/src/main/java/org/keycloak/services/resources/SaasService.java @@ -95,6 +95,33 @@ public class SaasService { } } + @Path("ping") + @GET + @NoCache + @Produces("text/plain") + public String ping(@Context HttpHeaders headers) { + logger.info("************** GET PING"); + for (String header : headers.getRequestHeaders().keySet()) { + logger.info(" " + header + ": " + headers.getHeaderString(header)); + } + return "ping"; + } + + @Path("ping") + @OPTIONS + @NoCache + @Produces("text/plain") + public Response optionsPing(@Context HttpHeaders headers) { + logger.info("************** OPTIONS PING"); + for (String header : headers.getRequestHeaders().keySet()) { + logger.info(" " + header + ": " + headers.getHeaderString(header)); + } + return Response.ok() + .header("Access-Control-Allow-Origin", "*") + .header("Access-Control-Allow-Headers", HttpHeaders.AUTHORIZATION).build(); + } + + @Path("keepalive") @GET @NoCache