Skip to content

Commit bc6138c

Browse files
ChrisKianbrianchandotcom
authored andcommitted
LPS-203432 Pass along Cross-Site Request Forgery token in header, for cases where locally-executed REST calls are required. This prevents the regression from LPS-203799 from occurring, while resolving the originally scoped issue from LPS-203432.
1 parent 27b51db commit bc6138c

File tree

1 file changed

+14
-0
lines changed
  • modules/apps/portal-vulcan/portal-vulcan-impl/src/main/java/com/liferay/portal/vulcan/internal/template/servlet

1 file changed

+14
-0
lines changed

modules/apps/portal-vulcan/portal-vulcan-impl/src/main/java/com/liferay/portal/vulcan/internal/template/servlet/RESTClientHttpRequest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.liferay.portal.kernel.servlet.HttpHeaders;
99
import com.liferay.portal.kernel.servlet.HttpMethods;
10+
import com.liferay.portal.kernel.servlet.PortalSessionThreadLocal;
1011
import com.liferay.portal.kernel.util.ContentTypes;
1112
import com.liferay.portal.kernel.util.HashMapBuilder;
1213
import com.liferay.portal.kernel.util.PortalUtil;
@@ -68,6 +69,19 @@ public RESTClientHttpRequest(
6869

6970
return locale.toLanguageTag();
7071
}
72+
).put(
73+
"X-CSRF-Token",
74+
() -> {
75+
HttpSession httpSession =
76+
PortalSessionThreadLocal.getHttpSession();
77+
78+
if (httpSession != null) {
79+
return (String)httpSession.getAttribute(
80+
WebKeys.AUTHENTICATION_TOKEN + "#CSRF");
81+
}
82+
83+
return null;
84+
}
7185
).build();
7286
_httpServletRequest = httpServletRequest;
7387
}

0 commit comments

Comments
 (0)