Skip to content

Commit

Permalink
fixed auth cookie missing secure flag
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Jul 18, 2022
1 parent b8d78a9 commit 02ee9e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions para-core/src/main/java/com/erudika/para/core/App.java
Expand Up @@ -926,8 +926,8 @@ public void addDatatype(String pluralDatatype, String datatype) {
return;
}
if (getDatatypes().size() >= Para.getConfig().maxDatatypesPerApp()) {
LoggerFactory.getLogger(App.class).warn("Maximum number of types per app reached - {}.",
Para.getConfig().maxDatatypesPerApp());
LoggerFactory.getLogger(App.class).warn("Maximum number of types per app reached ({}) for app {}.",
Para.getConfig().maxDatatypesPerApp(), getAppIdentifier());
return;
}
if (!getDatatypes().containsKey(pluralDatatype) && !getDatatypes().containsValue(datatype) &&
Expand Down
Expand Up @@ -18,6 +18,7 @@
package com.erudika.para.server.utils;

import com.erudika.para.core.utils.Para;
import com.erudika.para.server.security.SecurityUtils;
import java.util.TimeZone;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -160,6 +161,9 @@ public static void setAuthCookie(String name, String value, int maxAge,
sb.append("Expires=").append(expires).append(";");
sb.append("Max-Age=").append(maxAge).append(";");
sb.append("HttpOnly;");
if (StringUtils.startsWithIgnoreCase(SecurityUtils.getRedirectUrl(request), "https://") || request.isSecure()) {
sb.append("Secure;");
}
sb.append("SameSite=Lax");
response.addHeader(javax.ws.rs.core.HttpHeaders.SET_COOKIE, sb.toString());
}
Expand Down

0 comments on commit 02ee9e4

Please sign in to comment.