Fix session riding for SSE
Change-Id: Ibdc2e6626754b28682f3d0be236ef06e1fda2cea
diff --git a/Changes b/Changes
index 5c19bc3..7479668 100644
--- a/Changes
+++ b/Changes
@@ -1,2 +1,5 @@
+0.2.4 2021-04-27
+ - Fix temporary session-riding capabilities.
+
0.2.3 2021-03-24
- Added trail info to RTF export.
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 61fe2a7..f0da782 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<groupId>de.ids_mannheim.korap</groupId>
<artifactId>KalamarExportPlugin</artifactId>
<packaging>jar</packaging>
- <version>0.2.3</version>
+ <version>0.2.4</version>
<name>KalamarExportPlugin</name>
<url>http://maven.apache.org</url>
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java b/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
index 7fe4233..8382254 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
@@ -18,7 +18,7 @@
// Version of Export Plugin
public static final int VERSION_MAJOR = 0;
public static final int VERSION_MINOR = 2;
- public static final int VERSION_PATCHLEVEL = 2;
+ public static final int VERSION_PATCHLEVEL = 4;
private static Properties prop;
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/Service.java b/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
index 8890406..cbe88db 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
@@ -500,8 +500,16 @@
}
}).start();
+ String origin = prop.getProperty("server.origin","*");
+ if (servletReq != null) {
+ // This is temporary to allow for session riding
+ origin = servletReq.getHeader("Origin");
+ };
+
return Response.ok(eventOutput, SseFeature.SERVER_SENT_EVENTS_TYPE)
- .header("Access-Control-Allow-Origin", "*")
+ .header("Access-Control-Allow-Origin", origin)
+ .header("Access-Control-Allow-Credentials", "true")
+ .header("Vary","Origin")
.build();
};
@@ -617,9 +625,10 @@
// Iterate through all cookies for a Kalamar session
for (int i = 0; i < cookies.length; i++) {
-
- // Check the valid path
- if (cookiePath != "" && cookies[i].getPath() != cookiePath)
+
+ // Check the valid path (often path is not set when sent)
+ if (cookiePath != "" && cookies[i].getPath() != "" &&
+ cookies[i].getPath() != cookiePath)
continue;
// Ignore irrelevant cookies
diff --git a/src/main/resources/assets/export.js b/src/main/resources/assets/export.js
index af55b93..f9db882 100644
--- a/src/main/resources/assets/export.js
+++ b/src/main/resources/assets/export.js
@@ -78,7 +78,8 @@
let relocationURL;
- const sse = new EventSource(target);
+ const sse = new EventSource(target, { withCredentials : true });
+ console.log("Credentials: " + sse.withCredentials);
const prog = document.getElementById('progress');
sse.addEventListener('Progress', function (e) {