mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
added a challenge for mercurial hooks
This commit is contained in:
@@ -45,6 +45,7 @@ import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.io.RegexResourceProcessor;
|
||||
import sonia.scm.io.ResourceProcessor;
|
||||
import sonia.scm.repository.HgConfig;
|
||||
import sonia.scm.repository.HgHookManager;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.Util;
|
||||
@@ -86,13 +87,16 @@ public class HgHookScriptFilter extends HttpFilter
|
||||
*
|
||||
* @param context
|
||||
* @param handler
|
||||
* @param hookManager
|
||||
*/
|
||||
@Inject
|
||||
public HgHookScriptFilter(SCMContextProvider context,
|
||||
HgRepositoryHandler handler)
|
||||
HgRepositoryHandler handler,
|
||||
HgHookManager hookManager)
|
||||
{
|
||||
this.context = context;
|
||||
this.handler = handler;
|
||||
this.hookManager = hookManager;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
@@ -183,6 +187,7 @@ public class HgHookScriptFilter extends HttpFilter
|
||||
rp.addVariable("python", config.getPythonBinary());
|
||||
rp.addVariable("path", Util.nonNull(config.getPythonPath()));
|
||||
rp.addVariable("url", url);
|
||||
rp.addVariable("challenge", hookManager.getChallenge());
|
||||
rp.process(input, output);
|
||||
script.setExecutable(true);
|
||||
}
|
||||
@@ -201,6 +206,9 @@ public class HgHookScriptFilter extends HttpFilter
|
||||
/** Field description */
|
||||
private HgRepositoryHandler handler;
|
||||
|
||||
/** Field description */
|
||||
private HgHookManager hookManager;
|
||||
|
||||
/** Field description */
|
||||
private volatile boolean written = false;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ package sonia.scm.web;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
|
||||
import sonia.scm.plugin.ext.Extension;
|
||||
import sonia.scm.repository.HgHookManager;
|
||||
import sonia.scm.web.filter.BasicAuthenticationFilter;
|
||||
|
||||
/**
|
||||
@@ -63,6 +64,7 @@ public class HgServletModule extends ServletModule
|
||||
@Override
|
||||
protected void configureServlets()
|
||||
{
|
||||
bind(HgHookManager.class);
|
||||
|
||||
// write hook script
|
||||
filter(MAPPING_ALL).through(HgHookScriptFilter.class);
|
||||
|
||||
Reference in New Issue
Block a user