KEYCLOAK-5141 Return '*' in Cors requests when '*' is in list of permitted origins. Stop caching well-known information as it can change. (#4290)

This commit is contained in:
Stian Thorgersen authored and GitHub committed 2017-07-05 09:25:21 +02:00
1 parent eba8dac47d
commit c95aace6e0
3 files changed
+41 -11

No files matched your search

@@ -133,7 +133,11 @@ public class Cors {
return builder.build();
}
builder.header(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
if (allowedOrigins != null && allowedOrigins.contains(ACCESS_CONTROL_ALLOW_ORIGIN_WILDCARD)) {
builder.header(ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_ALLOW_ORIGIN_WILDCARD);
} else {
builder.header(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
}
if (preflight) {
if (allowedMethods != null) {
@@ -178,7 +182,11 @@ public class Cors {
logger.debug("build CORS headers and return");
response.getOutputHeaders().add(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
if (allowedOrigins.contains(ACCESS_CONTROL_ALLOW_ORIGIN_WILDCARD)) {
response.getOutputHeaders().add(ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_ALLOW_ORIGIN_WILDCARD);
} else {
response.getOutputHeaders().add(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
}
if (preflight) {
if (allowedMethods != null) {
@@ -260,8 +260,7 @@ public class RealmsResource {
WellKnownProvider wellKnown = session.getProvider(WellKnownProvider.class, providerName);
if (wellKnown != null) {
ResponseBuilder responseBuilder = Response.ok(wellKnown.getConfig())
.cacheControl(CacheControlUtil.getDefaultCacheControl());
ResponseBuilder responseBuilder = Response.ok(wellKnown.getConfig()).cacheControl(CacheControlUtil.noCache());
return Cors.add(request, responseBuilder).allowedOrigins("*").auth().build();
}