Skip to content

Commit 57ca0ee

Browse files
committed
Fix: make server.secure-cookies consistent when not/using Redis
1 parent 540ba5c commit 57ca0ee

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/ContainerProxyApplication.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public class ContainerProxyApplication {
8686

8787
private static final String PROP_PROXY_SAME_SITE_COOKIE = "proxy.same-site-cookie";
8888
private static final String SAME_SITE_COOKIE_DEFAULT_VALUE = "Lax";
89+
private static final String PROP_SERVER_SECURE_COOKIES = "server.secure-cookies";
90+
private static final Boolean SECURE_COOKIES_DEFAULT_VALUE = false;
8991

9092
public static void main(String[] args) {
9193
SpringApplication app = new SpringApplication(ContainerProxyApplication.class);
@@ -116,6 +118,7 @@ public void init() {
116118
String sameSiteCookie = environment.getProperty(PROP_PROXY_SAME_SITE_COOKIE, SAME_SITE_COOKIE_DEFAULT_VALUE);
117119
log.debug("Setting sameSiteCookie policy to {}" , sameSiteCookie);
118120
defaultCookieSerializer.setSameSite(sameSiteCookie);
121+
defaultCookieSerializer.setUseSecureCookie(environment.getProperty(PROP_SERVER_SECURE_COOKIES, Boolean.class, SECURE_COOKIES_DEFAULT_VALUE));
119122
}
120123

121124
@Autowired(required = false)
@@ -133,11 +136,11 @@ public UndertowServletWebServerFactory servletContainer() {
133136

134137
String sameSiteCookie = environment.getProperty(PROP_PROXY_SAME_SITE_COOKIE, SAME_SITE_COOKIE_DEFAULT_VALUE);
135138
log.debug("Setting sameSiteCookie policy for session cookies to {}" , sameSiteCookie);
136-
info.addOuterHandlerChainWrapper(defaultHandler -> new SameSiteCookieHandler(defaultHandler, sameSiteCookie, null, true, true, true));
139+
info.addOuterHandlerChainWrapper(defaultHandler -> new SameSiteCookieHandler(defaultHandler, sameSiteCookie, null, true, true, false));
137140

138141
ServletSessionConfig sessionConfig = new ServletSessionConfig();
139142
sessionConfig.setHttpOnly(true);
140-
sessionConfig.setSecure(Boolean.parseBoolean(environment.getProperty("server.secure-cookies", "false")));
143+
sessionConfig.setSecure(environment.getProperty(PROP_SERVER_SECURE_COOKIES, Boolean.class, SECURE_COOKIES_DEFAULT_VALUE));
141144
info.setServletSessionConfig(sessionConfig);
142145
if (sessionManagerFactory != null) {
143146
info.setSessionManagerFactory(sessionManagerFactory);

0 commit comments

Comments
 (0)