Merge branch 'stable-3.3' into stable-3.4 * stable-3.3: Add Oauth workflow scope Change-Id: I64c12026a905ea5df794bc69d31cec9f6871da4d
diff --git a/github-oauth/pom.xml b/github-oauth/pom.xml index 7a45b1d..409b0ee 100644 --- a/github-oauth/pom.xml +++ b/github-oauth/pom.xml
@@ -21,7 +21,7 @@ <parent> <groupId>com.googlesource.gerrit.plugins.github</groupId> <artifactId>github-parent</artifactId> - <version>3.3.0</version> + <version>3.4.0-rc0</version> </parent> <artifactId>github-oauth</artifactId> <name>Gerrit Code Review - GitHub OAuth login</name>
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubMyselfWrapper.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubMyselfWrapper.java index 247d6a6..9bdae85 100644 --- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubMyselfWrapper.java +++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubMyselfWrapper.java
@@ -19,7 +19,6 @@ import java.util.Date; import java.util.List; import java.util.Map; -import java.util.Set; import org.kohsuke.github.GHEmail; import org.kohsuke.github.GHEventInfo; import org.kohsuke.github.GHGist;
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthFilter.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthFilter.java index d68749e..5025002 100644 --- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthFilter.java +++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/OAuthFilter.java
@@ -38,8 +38,8 @@ private static Pattern GIT_HTTP_REQUEST_PATTERN = Pattern.compile(GitOverHttpServlet.URL_REGEX); private static final Set<String> GERRIT_STATIC_RESOURCES_EXTS = Sets.newHashSet("css", "png", "jpg", "gif", "woff", "otf", "ttf", "map", "js", "swf", "txt"); - private static final Set<String> GERRIT_WHITELISTED_PATHS = Sets.newHashSet("Documentation"); - private static final Set<String> GERRIT_WHITELISTED_PAGES = Sets.newHashSet("scope.html"); + private static final Set<String> GERRIT_ALLOWED_PATHS = Sets.newHashSet("Documentation"); + private static final Set<String> GERRIT_ALLOWED_PAGES = Sets.newHashSet("scope.html"); private final GitHubOAuthConfig config; private final OAuthWebFilter webFilter; @@ -78,7 +78,7 @@ return isStaticResource(httpRequest) || isRpcCall(httpRequest) || isAuthenticatedRestCall(httpRequest) - || isWhitelisted(httpRequest); + || isAllowed(httpRequest); } private static boolean isAuthenticatedRestCall(HttpServletRequest httpRequest) { @@ -95,11 +95,11 @@ return GERRIT_STATIC_RESOURCES_EXTS.contains(pathExt.toLowerCase()); } - private static boolean isWhitelisted(HttpServletRequest httpRequest) { + private static boolean isAllowed(HttpServletRequest httpRequest) { String[] requestPathParts = httpRequest.getRequestURI().split("/"); return (requestPathParts.length > 1 - && (GERRIT_WHITELISTED_PATHS.contains(requestPathParts[1]) - || GERRIT_WHITELISTED_PAGES.contains(requestPathParts[requestPathParts.length - 1]))); + && (GERRIT_ALLOWED_PATHS.contains(requestPathParts[1]) + || GERRIT_ALLOWED_PAGES.contains(requestPathParts[requestPathParts.length - 1]))); } private static boolean isRpcCall(HttpServletRequest httpRequest) {
diff --git a/github-plugin/pom.xml b/github-plugin/pom.xml index 58fcd13..1e79934 100644 --- a/github-plugin/pom.xml +++ b/github-plugin/pom.xml
@@ -20,7 +20,7 @@ <parent> <artifactId>github-parent</artifactId> <groupId>com.googlesource.gerrit.plugins.github</groupId> - <version>3.3.0</version> + <version>3.4.0-rc0</version> </parent> <artifactId>github-plugin</artifactId> @@ -135,7 +135,7 @@ <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> - <version>2.1</version> + <version>2.8.6</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId>
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java index 21d6732..5f74078 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/group/GitHubGroupBackend.java
@@ -25,7 +25,7 @@ import com.google.gerrit.entities.AccountGroup.UUID; import com.google.gerrit.entities.GroupDescription.Basic; import com.google.gerrit.entities.GroupReference; -import com.google.gerrit.server.IdentifiedUser; +import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.account.GroupBackend; import com.google.gerrit.server.account.GroupMembership; import com.google.gerrit.server.project.ProjectState; @@ -111,7 +111,7 @@ } @Override - public GroupMembership membershipsOf(IdentifiedUser user) { + public GroupMembership membershipsOf(CurrentUser user) { String username = user.getUserName().orElse(null); if (Strings.isNullOrEmpty(username)) { return GroupMembership.EMPTY;
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/RemoteSiteUser.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/RemoteSiteUser.java index 26def83..f80af85 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/RemoteSiteUser.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/RemoteSiteUser.java
@@ -35,4 +35,9 @@ public GroupMembership getEffectiveGroups() { return effectiveGroups; } + + @Override + public Object getCacheKey() { + return effectiveGroups.getKnownGroups(); + } }
diff --git a/pom.xml b/pom.xml index 0be79b3..cedbde3 100644 --- a/pom.xml +++ b/pom.xml
@@ -18,7 +18,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.googlesource.gerrit.plugins.github</groupId> <artifactId>github-parent</artifactId> - <version>3.3.0</version> + <version>3.4.0-rc0</version> <name>Gerrit Code Review - GitHub integration</name> <url>http://www.gerritforge.com</url> <packaging>pom</packaging> @@ -290,6 +290,12 @@ </repositories> <dependencies> <dependency> + <groupId>com.ryanharter.auto.value</groupId> + <artifactId>auto-value-gson</artifactId> + <version>1.3.0</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.16</version>