diff --git a/modules/dcache/src/main/java/org/dcache/http/HttpTransferService.java b/modules/dcache/src/main/java/org/dcache/http/HttpTransferService.java index ce5f949e9a4..3a14039daf7 100644 --- a/modules/dcache/src/main/java/org/dcache/http/HttpTransferService.java +++ b/modules/dcache/src/main/java/org/dcache/http/HttpTransferService.java @@ -81,6 +81,15 @@ public HttpTransferService() super("http"); } + CorsConfigBuilder corsConfigBuilder() + { + return CorsConfigBuilder.forAnyOrigin() + .allowNullOrigin() + .allowedRequestMethods(GET, PUT, HEAD) + .allowedRequestHeaders(CONTENT_TYPE, AUTHORIZATION, CONTENT_MD5, + "Want-Digest", "suppress-www-authenticate"); + } + public int getChunkSize() { return chunkSize; @@ -175,13 +184,7 @@ protected void addChannelHandlers(ChannelPipeline pipeline) pipeline.addLast("custom-headers", new CustomResponseHeadersHandler(customHeaders)); } - CorsConfig corsConfig = CorsConfigBuilder.forAnyOrigin() - .allowNullOrigin() - .allowedRequestMethods(GET, PUT, HEAD) - .allowedRequestHeaders(CONTENT_TYPE, AUTHORIZATION, CONTENT_MD5, - "Want-Digest", "suppress-www-authenticate") - .build(); - pipeline.addLast("cors", new CorsHandler(corsConfig)); + pipeline.addLast("cors", new CorsHandler(corsConfigBuilder().build())); pipeline.addLast("transfer", new HttpPoolRequestHandler(this, chunkSize)); } diff --git a/modules/dcache/src/main/java/org/dcache/http/HttpsTransferService.java b/modules/dcache/src/main/java/org/dcache/http/HttpsTransferService.java index 16200b88e31..20b7b39a626 100644 --- a/modules/dcache/src/main/java/org/dcache/http/HttpsTransferService.java +++ b/modules/dcache/src/main/java/org/dcache/http/HttpsTransferService.java @@ -26,6 +26,7 @@ import eu.emi.security.authn.x509.CrlCheckingMode; import eu.emi.security.authn.x509.OCSPCheckingMode; import io.netty.channel.ChannelPipeline; +import io.netty.handler.codec.http.cors.CorsConfigBuilder; import io.netty.handler.ssl.SslHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,6 +73,12 @@ static String getHost(URI url) : host; } + @Override + CorsConfigBuilder corsConfigBuilder() + { + return super.corsConfigBuilder().allowCredentials(); + } + @Override protected URI getUri(HttpProtocolInfo protocolInfo, int port, UUID uuid) throws SocketException, CacheException, URISyntaxException {