Commit 2466ecbc authored by mhellka's avatar mhellka
Browse files

Added X-Transaction to allowed CORS headers.

parent be5a1158
Pipeline #127432 passed with stages
in 11 minutes and 14 seconds
......@@ -20,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.gwdg.cdstar.Utils;
import de.gwdg.cdstar.rest.utils.SessionHelper;
/**
* Filter to add CORS simple-request headers and handle CORS preflight requests.
......@@ -43,6 +44,7 @@ public class CORSFilter implements Filter {
final Set<String> expose = new HashSet<>();
allow.addAll(Arrays.asList("Cache-Control", "Content-Type", "Authorization", "X-HTTP-Method-Override"));
allow.add(SessionHelper.HEADER_TRANSACTION);
expose.addAll(Arrays.asList("Location"));
// TODO: Find a way for plugins to add their headers and settings to this filter
......@@ -50,6 +52,7 @@ public class CORSFilter implements Filter {
"Tus-Extension", "Tus-Max-Size", "Upload-Metadata");
allow.addAll(tusHeaders);
expose.addAll(tusHeaders);
setExposeHeaders(expose);
setAllowHeaders(allow);
......
......@@ -22,6 +22,8 @@ import de.gwdg.cdstar.web.common.model.ErrorResponse;
public class SessionHelper {
public static final String QUERY_TRANSACTION = "_ta";
public static final String HEADER_TRANSACTION = "X-Transaction";
private static final Logger log = LoggerFactory.getLogger(SessionHelper.class);
/**
......@@ -86,9 +88,9 @@ public class SessionHelper {
}
private static String getExplicitTransactionID(RestContext ctx) {
String tx = ctx.getHeader("X-Transaction");
String tx = ctx.getHeader(HEADER_TRANSACTION);
if (tx == null)
tx = ctx.getQueryParam("_ta");
tx = ctx.getQueryParam(QUERY_TRANSACTION);
return tx;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment