You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jk...@apache.org on 2020/11/03 11:10:44 UTC
[unomi] branch unomi-1.4.x updated: UNOMI-391: provide SameSite=Lax
configuration on profile id cookie (#209)
This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch unomi-1.4.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/unomi-1.4.x by this push:
new 4607308 UNOMI-391: provide SameSite=Lax configuration on profile id cookie (#209)
4607308 is described below
commit 46073080adf50dc9eb95857874d95e169a4c0b26
Author: kevan Jahanshahi <ke...@jahia.com>
AuthorDate: Tue Nov 3 12:07:18 2020 +0100
UNOMI-391: provide SameSite=Lax configuration on profile id cookie (#209)
---
.../baseplugin/actions/MergeProfilesOnPropertyAction.java | 13 ++++++-------
wab/src/main/java/org/apache/unomi/web/HttpUtils.java | 14 +++++++-------
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
index c1e89f4..6eb0f0d 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
@@ -204,13 +204,12 @@ public class MergeProfilesOnPropertyAction implements ActionExecutor {
if (response instanceof HttpServletResponse) {
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
if (!(profile instanceof Persona)) {
- Cookie profileIdCookie = new Cookie(profileIdCookieName, profile.getItemId());
- profileIdCookie.setPath("/");
- if (profileIdCookieDomain != null && !profileIdCookieDomain.equals("")) {
- profileIdCookie.setDomain(profileIdCookieDomain);
- }
- profileIdCookie.setMaxAge(cookieAgeInSeconds);
- httpServletResponse.addCookie(profileIdCookie);
+ httpServletResponse.addHeader("Set-Cookie",
+ profileIdCookieName + "=" + profile.getItemId() +
+ "; Path=/" +
+ "; Max-Age=" + cookieAgeInSeconds +
+ (StringUtils.isNotBlank(profileIdCookieDomain) ? ("; Domain=" + profileIdCookieDomain) : "") +
+ "; SameSite=Lax");
}
}
}
diff --git a/wab/src/main/java/org/apache/unomi/web/HttpUtils.java b/wab/src/main/java/org/apache/unomi/web/HttpUtils.java
index 6837c0d..a6c34a3 100644
--- a/wab/src/main/java/org/apache/unomi/web/HttpUtils.java
+++ b/wab/src/main/java/org/apache/unomi/web/HttpUtils.java
@@ -17,6 +17,7 @@
package org.apache.unomi.web;
+import org.apache.commons.lang3.StringUtils;
import org.apache.unomi.api.Persona;
import org.apache.unomi.api.Profile;
@@ -117,13 +118,12 @@ public class HttpUtils {
if (response instanceof HttpServletResponse) {
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
if (!(profile instanceof Persona)) {
- Cookie profileIdCookie = new Cookie(profileIdCookieName, profile.getItemId());
- profileIdCookie.setPath("/");
- if (profileIdCookieDomain != null && !profileIdCookieDomain.equals("")) {
- profileIdCookie.setDomain(profileIdCookieDomain);
- }
- profileIdCookie.setMaxAge(profileIdCookieMaxAgeInSeconds);
- httpServletResponse.addCookie(profileIdCookie);
+ httpServletResponse.addHeader("Set-Cookie",
+ profileIdCookieName + "=" + profile.getItemId() +
+ "; Path=/" +
+ "; Max-Age=" + profileIdCookieMaxAgeInSeconds +
+ (StringUtils.isNotBlank(profileIdCookieDomain) ? ("; Domain=" + profileIdCookieDomain) : "") +
+ "; SameSite=Lax");
}
}
}