Allow download schemes to support but not require authentication

* If the current user is unauthenticated and the scheme requires
  authentication, don't list it.

* If the patch is not visible to anonymous users and the scheme
  does not support authentication, don't list it.

In particular, since https on googlesource.com supports but does not
require authentication, this should allow the https download links to
be shown again on private changes on that gerrit instance (like they
were before ea62148983).

Change-Id: Icf3177c0f90062df4d3264375a6a6035251b91cf
This commit is contained in:
Jonathan Nieder
2013-10-23 12:24:21 -07:00
parent 0de671cd65
commit d4b0526403
2 changed files with 6 additions and 1 deletions

View File

@@ -29,6 +29,11 @@ public abstract class DownloadScheme {
/** @return whether this scheme requires authentication */
public abstract boolean isAuthRequired();
/** @return whether this scheme supports authentication */
public boolean isAuthSupported() {
return isAuthRequired();
}
/** @return whether the download scheme is enabled */
public abstract boolean isEnabled();
}

View File

@@ -855,7 +855,7 @@ public class ChangeJson {
}
ChangeControl ctl = control(cd);
if (!scheme.isAuthRequired()
if (!scheme.isAuthSupported()
&& !ctl.forUser(anonymous).isPatchVisible(in, db.get())) {
continue;
}