Install "git-lfs-authenticate" SSH command when lfs.plugin is configured
SSH command registration was extended so that command gets registered only in case when plugin is configured in gerrit.config. Change-Id: Iffaf00775bdf1242e1fbe1dea15e5ce0bf912079 Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
This commit is contained in:
committed by
Jacek Centkowski
parent
f104ccd30c
commit
31235233d0
@@ -87,6 +87,7 @@ import com.google.gerrit.sshd.SshKeyCacheImpl;
|
|||||||
import com.google.gerrit.sshd.SshModule;
|
import com.google.gerrit.sshd.SshModule;
|
||||||
import com.google.gerrit.sshd.commands.DefaultCommandModule;
|
import com.google.gerrit.sshd.commands.DefaultCommandModule;
|
||||||
import com.google.gerrit.sshd.commands.IndexCommandsModule;
|
import com.google.gerrit.sshd.commands.IndexCommandsModule;
|
||||||
|
import com.google.gerrit.sshd.plugin.LfsPluginAuthCommand;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
@@ -439,7 +440,8 @@ public class Daemon extends SiteProgram {
|
|||||||
modules.add(new SshHostKeyModule());
|
modules.add(new SshHostKeyModule());
|
||||||
}
|
}
|
||||||
modules.add(new DefaultCommandModule(slave,
|
modules.add(new DefaultCommandModule(slave,
|
||||||
sysInjector.getInstance(DownloadConfig.class)));
|
sysInjector.getInstance(DownloadConfig.class),
|
||||||
|
sysInjector.getInstance(LfsPluginAuthCommand.Module.class)));
|
||||||
if (!slave && indexType == IndexType.LUCENE) {
|
if (!slave && indexType == IndexType.LUCENE) {
|
||||||
modules.add(new IndexCommandsModule());
|
modules.add(new IndexCommandsModule());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,13 @@ import com.google.gerrit.sshd.plugin.LfsPluginAuthCommand;
|
|||||||
/** Register the commands a Gerrit server supports. */
|
/** Register the commands a Gerrit server supports. */
|
||||||
public class DefaultCommandModule extends CommandModule {
|
public class DefaultCommandModule extends CommandModule {
|
||||||
private final DownloadConfig downloadConfig;
|
private final DownloadConfig downloadConfig;
|
||||||
|
private final LfsPluginAuthCommand.Module lfsPluginAuthModule;
|
||||||
|
|
||||||
public DefaultCommandModule(boolean slave, DownloadConfig downloadCfg) {
|
public DefaultCommandModule(boolean slave, DownloadConfig downloadCfg,
|
||||||
|
LfsPluginAuthCommand.Module module) {
|
||||||
slaveMode = slave;
|
slaveMode = slave;
|
||||||
downloadConfig = downloadCfg;
|
downloadConfig = downloadCfg;
|
||||||
|
lfsPluginAuthModule = module;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -124,7 +127,7 @@ public class DefaultCommandModule extends CommandModule {
|
|||||||
alias(logging, "ls", ListLoggingLevelCommand.class);
|
alias(logging, "ls", ListLoggingLevelCommand.class);
|
||||||
alias(logging, "set", SetLoggingLevelCommand.class);
|
alias(logging, "set", SetLoggingLevelCommand.class);
|
||||||
|
|
||||||
install(new LfsPluginAuthCommand.Module());
|
install(lfsPluginAuthModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sshEnabled() {
|
private boolean sshEnabled() {
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ package com.google.gerrit.sshd.plugin;
|
|||||||
|
|
||||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.sshd.CommandModule;
|
import com.google.gerrit.sshd.CommandModule;
|
||||||
import com.google.gerrit.sshd.SshCommand;
|
import com.google.gerrit.sshd.SshCommand;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.lib.Config;
|
||||||
import org.kohsuke.args4j.Argument;
|
import org.kohsuke.args4j.Argument;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -33,12 +35,21 @@ public class LfsPluginAuthCommand extends SshCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Module extends CommandModule {
|
public static class Module extends CommandModule {
|
||||||
|
private final boolean pluginProvided;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Module(@GerritServerConfig Config cfg) {
|
||||||
|
pluginProvided = cfg.getString("lfs", null, "plugin") != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
if (pluginProvided) {
|
||||||
command("git-lfs-authenticate").to(LfsPluginAuthCommand.class);
|
command("git-lfs-authenticate").to(LfsPluginAuthCommand.class);
|
||||||
DynamicItem.itemOf(binder(), LfsSshPluginAuth.class);
|
DynamicItem.itemOf(binder(), LfsSshPluginAuth.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final DynamicItem<LfsSshPluginAuth> auth;
|
private final DynamicItem<LfsSshPluginAuth> auth;
|
||||||
private final Provider<CurrentUser> user;
|
private final Provider<CurrentUser> user;
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ import com.google.gerrit.sshd.SshKeyCacheImpl;
|
|||||||
import com.google.gerrit.sshd.SshModule;
|
import com.google.gerrit.sshd.SshModule;
|
||||||
import com.google.gerrit.sshd.commands.DefaultCommandModule;
|
import com.google.gerrit.sshd.commands.DefaultCommandModule;
|
||||||
import com.google.gerrit.sshd.commands.IndexCommandsModule;
|
import com.google.gerrit.sshd.commands.IndexCommandsModule;
|
||||||
|
import com.google.gerrit.sshd.plugin.LfsPluginAuthCommand;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.CreationException;
|
import com.google.inject.CreationException;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
@@ -356,7 +357,8 @@ public class WebAppInitializer extends GuiceServletContextListener
|
|||||||
modules.add(sysInjector.getInstance(SshModule.class));
|
modules.add(sysInjector.getInstance(SshModule.class));
|
||||||
modules.add(new SshHostKeyModule());
|
modules.add(new SshHostKeyModule());
|
||||||
modules.add(new DefaultCommandModule(false,
|
modules.add(new DefaultCommandModule(false,
|
||||||
sysInjector.getInstance(DownloadConfig.class)));
|
sysInjector.getInstance(DownloadConfig.class),
|
||||||
|
sysInjector.getInstance(LfsPluginAuthCommand.Module.class)));
|
||||||
if (indexType == IndexType.LUCENE) {
|
if (indexType == IndexType.LUCENE) {
|
||||||
modules.add(new IndexCommandsModule());
|
modules.add(new IndexCommandsModule());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user