Skip to content

Commit

Permalink
#1849 Set / path to CSRF cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-podolskiy90 committed Oct 10, 2022
1 parent 7312953 commit 3c8da1f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/org/gbif/ipt/struts2/CsrfLoginInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.StrutsStatics;

import com.google.inject.Inject;
Expand Down Expand Up @@ -75,7 +76,7 @@ public String intercept(ActionInvocation invocation) throws Exception {

try {
URI iptUri = URI.create(cfg.getBaseUrl());
csrfCookie.setPath(iptUri.getPath());
csrfCookie.setPath(StringUtils.isEmpty(iptUri.getPath()) ? "/" : iptUri.getPath());
csrfCookie.setDomain(iptUri.getHost());
csrfCookie.setSecure(iptUri.getScheme().equalsIgnoreCase("https"));
} catch (Exception e) {
Expand Down

0 comments on commit 3c8da1f

Please sign in to comment.