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 9530d1f6d43..ab4c85c36e9 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) throws Exception 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 0606157c32f..1f01ea64be4 100644 --- a/modules/dcache/src/main/java/org/dcache/http/HttpsTransferService.java +++ b/modules/dcache/src/main/java/org/dcache/http/HttpsTransferService.java @@ -28,6 +28,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; @@ -123,6 +124,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 {