Correctly identify Git-over-HTTP operations
Git operations over HTTP should be classified as using AccessPath.GIT and not WEB_UI. This ensures RefControl will correctly test for Create, Push or Delete access on a reference instead of Owner. Change-Id: I57936929c0d12358f44bbf3959c0e11f12bc823b
This commit is contained in:
@@ -34,6 +34,8 @@ import com.google.inject.Module;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.servlet.RequestScoped;
|
||||
|
||||
import org.eclipse.jgit.http.server.GitSmartHttpTools;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -65,7 +67,7 @@ public final class CacheBasedWebSession implements WebSession {
|
||||
private final AuthConfig authConfig;
|
||||
private final Provider<AnonymousUser> anonymousProvider;
|
||||
private final IdentifiedUser.RequestFactory identified;
|
||||
private AccessPath accessPath = AccessPath.WEB_UI;
|
||||
private AccessPath accessPath;
|
||||
private Cookie outCookie;
|
||||
private AuthMethod authMethod;
|
||||
|
||||
@@ -85,6 +87,12 @@ public final class CacheBasedWebSession implements WebSession {
|
||||
this.anonymousProvider = anonymousProvider;
|
||||
this.identified = identified;
|
||||
|
||||
if (GitSmartHttpTools.isGitClient(request)) {
|
||||
accessPath = AccessPath.GIT;
|
||||
} else {
|
||||
accessPath = AccessPath.WEB_UI;
|
||||
}
|
||||
|
||||
final String cookie = readCookie();
|
||||
if (cookie != null) {
|
||||
key = new Key(cookie);
|
||||
@@ -161,11 +169,6 @@ public final class CacheBasedWebSession implements WebSession {
|
||||
authMethod = meth;
|
||||
}
|
||||
|
||||
/** Change the access path from the default of {@link AccessPath#WEB_UI}. */
|
||||
public void setAccessPath(AccessPath path) {
|
||||
accessPath = path;
|
||||
}
|
||||
|
||||
/** Set the user account for this current request only. */
|
||||
public void setUserAccountId(Account.Id id, AuthMethod method) {
|
||||
key = new Key("id:" + id);
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.google.common.cache.Cache;
|
||||
import com.google.gerrit.common.data.Capable;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.AccessPath;
|
||||
import com.google.gerrit.server.AnonymousUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.cache.CacheModule;
|
||||
@@ -190,7 +189,6 @@ public class GitOverHttpServlet extends GitServlet {
|
||||
UploadPack up = new UploadPack(repo);
|
||||
up.setPackConfig(config.getPackConfig());
|
||||
up.setTimeout(config.getTimeout());
|
||||
session.get().setAccessPath(AccessPath.GIT);
|
||||
return up;
|
||||
}
|
||||
}
|
||||
@@ -266,7 +264,6 @@ public class GitOverHttpServlet extends GitServlet {
|
||||
rp.setTimeout(config.getTimeout());
|
||||
rp.setMaxObjectSizeLimit(config.getMaxObjectSizeLimit());
|
||||
req.setAttribute(ATT_RC, rc);
|
||||
session.get().setAccessPath(AccessPath.GIT);
|
||||
return rp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ package com.google.gerrit.httpd;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountExternalId;
|
||||
import com.google.gerrit.server.AccessPath;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.account.AuthMethod;
|
||||
import com.google.gerrit.server.account.AuthResult;
|
||||
@@ -36,9 +35,6 @@ public interface WebSession {
|
||||
|
||||
public void login(AuthResult res, AuthMethod meth, boolean rememberMe);
|
||||
|
||||
/** Change the access path from the default of {@link AccessPath#WEB_UI}. */
|
||||
public void setAccessPath(AccessPath path);
|
||||
|
||||
/** Set the user account for this current request only. */
|
||||
public void setUserAccountId(Account.Id id, AuthMethod method);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user