Add ability to set authentication cookie's domain
Change-Id: Ib74c95dd298f19df689c9843ee3144f387505865
This commit is contained in:
@@ -383,6 +383,12 @@ Sets "path" attribute of the authentication cookie.
|
|||||||
+
|
+
|
||||||
If not set, HTTP request's path is used.
|
If not set, HTTP request's path is used.
|
||||||
|
|
||||||
|
[[auth.cookieDomain]]auth.cookieDomain::
|
||||||
|
+
|
||||||
|
Sets "domain" attribute of the authentication cookie.
|
||||||
|
+
|
||||||
|
If not set, HTTP request's domain is used.
|
||||||
|
|
||||||
[[auth.cookieSecure]]auth.cookieSecure::
|
[[auth.cookieSecure]]auth.cookieSecure::
|
||||||
+
|
+
|
||||||
Sets "secure" flag of the authentication cookie. If true, cookies
|
Sets "secure" flag of the authentication cookie. If true, cookies
|
||||||
|
@@ -17,6 +17,7 @@ package com.google.gerrit.httpd;
|
|||||||
import static java.util.concurrent.TimeUnit.HOURS;
|
import static java.util.concurrent.TimeUnit.HOURS;
|
||||||
|
|
||||||
import com.google.gerrit.common.data.HostPageData;
|
import com.google.gerrit.common.data.HostPageData;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.gerrit.httpd.WebSessionManager.Key;
|
import com.google.gerrit.httpd.WebSessionManager.Key;
|
||||||
import com.google.gerrit.httpd.WebSessionManager.Val;
|
import com.google.gerrit.httpd.WebSessionManager.Val;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
@@ -202,9 +203,9 @@ public abstract class CacheBasedWebSession implements WebSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String path = authConfig.getCookiePath();
|
String path = authConfig.getCookiePath();
|
||||||
if (path == null || path.isEmpty()) {
|
if (Strings.isNullOrEmpty(path)) {
|
||||||
path = request.getContextPath();
|
path = request.getContextPath();
|
||||||
if (path == null || path.isEmpty()) {
|
if (Strings.isNullOrEmpty(path)) {
|
||||||
path = "/";
|
path = "/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,6 +215,12 @@ public abstract class CacheBasedWebSession implements WebSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
outCookie = new Cookie(ACCOUNT_COOKIE, token);
|
outCookie = new Cookie(ACCOUNT_COOKIE, token);
|
||||||
|
|
||||||
|
String domain = authConfig.getCookieDomain();
|
||||||
|
if (!Strings.isNullOrEmpty(domain)) {
|
||||||
|
outCookie.setDomain(domain);
|
||||||
|
}
|
||||||
|
|
||||||
outCookie.setSecure(isSecure(request));
|
outCookie.setSecure(isSecure(request));
|
||||||
outCookie.setPath(path);
|
outCookie.setPath(path);
|
||||||
outCookie.setMaxAge(ageSeconds);
|
outCookie.setMaxAge(ageSeconds);
|
||||||
|
@@ -58,6 +58,7 @@ public class AuthConfig {
|
|||||||
private final List<OpenIdProviderPattern> trustedOpenIDs;
|
private final List<OpenIdProviderPattern> trustedOpenIDs;
|
||||||
private final List<OpenIdProviderPattern> allowedOpenIDs;
|
private final List<OpenIdProviderPattern> allowedOpenIDs;
|
||||||
private final String cookiePath;
|
private final String cookiePath;
|
||||||
|
private final String cookieDomain;
|
||||||
private final boolean cookieSecure;
|
private final boolean cookieSecure;
|
||||||
private final SignedToken emailReg;
|
private final SignedToken emailReg;
|
||||||
private final boolean allowRegisterNewEmail;
|
private final boolean allowRegisterNewEmail;
|
||||||
@@ -84,6 +85,7 @@ public class AuthConfig {
|
|||||||
trustedOpenIDs = toPatterns(cfg, "trustedOpenID");
|
trustedOpenIDs = toPatterns(cfg, "trustedOpenID");
|
||||||
allowedOpenIDs = toPatterns(cfg, "allowedOpenID");
|
allowedOpenIDs = toPatterns(cfg, "allowedOpenID");
|
||||||
cookiePath = cfg.getString("auth", null, "cookiepath");
|
cookiePath = cfg.getString("auth", null, "cookiepath");
|
||||||
|
cookieDomain = cfg.getString("auth", null, "cookiedomain");
|
||||||
cookieSecure = cfg.getBoolean("auth", "cookiesecure", false);
|
cookieSecure = cfg.getBoolean("auth", "cookiesecure", false);
|
||||||
trustContainerAuth = cfg.getBoolean("auth", "trustContainerAuth", false);
|
trustContainerAuth = cfg.getBoolean("auth", "trustContainerAuth", false);
|
||||||
enableRunAs = cfg.getBoolean("auth", null, "enableRunAs", true);
|
enableRunAs = cfg.getBoolean("auth", null, "enableRunAs", true);
|
||||||
@@ -179,6 +181,10 @@ public class AuthConfig {
|
|||||||
return cookiePath;
|
return cookiePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCookieDomain() {
|
||||||
|
return cookieDomain;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getCookieSecure() {
|
public boolean getCookieSecure() {
|
||||||
return cookieSecure;
|
return cookieSecure;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user