Fix FE web insecure cookie setting #26056 (#26057)

* Fix FE web insecure cookie setting #26056

* [Bug] FE web insecure cookie setting #26056
This commit is contained in:
Guangming Lu
2023-12-12 22:50:40 +08:00
committed by GitHub
parent 15553e6335
commit 5e374c6a35

View File

@ -104,7 +104,11 @@ public class BaseController {
protected void addSession(HttpServletRequest request, HttpServletResponse response, SessionValue value) {
String key = UUID.randomUUID().toString();
Cookie cookie = new Cookie(PALO_SESSION_ID, key);
cookie.setSecure(false);
if (Config.enable_https) {
cookie.setSecure(true);
} else {
cookie.setSecure(false);
}
cookie.setMaxAge(PALO_SESSION_EXPIRED_TIME);
cookie.setPath("/");
cookie.setHttpOnly(true);
@ -172,6 +176,12 @@ public class BaseController {
if (cookie.getName() != null && cookie.getName().equals(cookieName)) {
cookie.setMaxAge(age);
cookie.setPath("/");
cookie.setHttpOnly(true);
if (Config.enable_https) {
cookie.setSecure(true);
} else {
cookie.setSecure(false);
}
response.addCookie(cookie);
}
}