mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
replace ssl and forward parameters with base url to fix #32
This commit is contained in:
@@ -147,16 +147,20 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
this.servername = other.servername;
|
this.servername = other.servername;
|
||||||
this.dateFormat = other.dateFormat;
|
this.dateFormat = other.dateFormat;
|
||||||
this.pluginUrl = other.pluginUrl;
|
this.pluginUrl = other.pluginUrl;
|
||||||
this.sslPort = other.sslPort;
|
|
||||||
this.enableSSL = other.enableSSL;
|
|
||||||
this.enablePortForward = other.enablePortForward;
|
|
||||||
this.forwardPort = other.forwardPort;
|
|
||||||
this.anonymousAccessEnabled = other.anonymousAccessEnabled;
|
this.anonymousAccessEnabled = other.anonymousAccessEnabled;
|
||||||
this.adminUsers = other.adminUsers;
|
this.adminUsers = other.adminUsers;
|
||||||
this.adminGroups = other.adminGroups;
|
this.adminGroups = other.adminGroups;
|
||||||
this.enableProxy = other.enableProxy;
|
this.enableProxy = other.enableProxy;
|
||||||
this.proxyPort = other.proxyPort;
|
this.proxyPort = other.proxyPort;
|
||||||
this.proxyServer = other.proxyServer;
|
this.proxyServer = other.proxyServer;
|
||||||
|
this.forceBaseUrl = other.forceBaseUrl;
|
||||||
|
this.baseUrl = other.baseUrl;
|
||||||
|
|
||||||
|
// deprecated fields
|
||||||
|
this.sslPort = other.sslPort;
|
||||||
|
this.enableSSL = other.enableSSL;
|
||||||
|
this.enablePortForward = other.enablePortForward;
|
||||||
|
this.forwardPort = other.forwardPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,6 +199,18 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
return adminUsers;
|
return adminUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
public String getBaseUrl()
|
||||||
|
{
|
||||||
|
return baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -211,7 +227,9 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
* @deprecated use {@link #getBaseUrl()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public int getForwardPort()
|
public int getForwardPort()
|
||||||
{
|
{
|
||||||
return forwardPort;
|
return forwardPort;
|
||||||
@@ -266,7 +284,9 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
* @deprecated use {@link #getBaseUrl()} and {@link #isForceBaseUrl()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public int getSslPort()
|
public int getSslPort()
|
||||||
{
|
{
|
||||||
return sslPort;
|
return sslPort;
|
||||||
@@ -288,7 +308,9 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
* @deprecated use {@link #getBaseUrl()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean isEnablePortForward()
|
public boolean isEnablePortForward()
|
||||||
{
|
{
|
||||||
return enablePortForward;
|
return enablePortForward;
|
||||||
@@ -310,12 +332,26 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
* @deprecated use {@link #getBaseUrl()} and {@link #isForceBaseUrl()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public boolean isEnableSSL()
|
public boolean isEnableSSL()
|
||||||
{
|
{
|
||||||
return enableSSL;
|
return enableSSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
public boolean isForceBaseUrl()
|
||||||
|
{
|
||||||
|
return forceBaseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- set methods ----------------------------------------------------------
|
//~--- set methods ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -351,6 +387,18 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
this.anonymousAccessEnabled = anonymousAccessEnabled;
|
this.anonymousAccessEnabled = anonymousAccessEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param baseUrl
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
public void setBaseUrl(String baseUrl)
|
||||||
|
{
|
||||||
|
this.baseUrl = baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -367,7 +415,9 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param enablePortForward
|
* @param enablePortForward
|
||||||
|
* @deprecated use {@link #setBaseUrl(String)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setEnablePortForward(boolean enablePortForward)
|
public void setEnablePortForward(boolean enablePortForward)
|
||||||
{
|
{
|
||||||
this.enablePortForward = enablePortForward;
|
this.enablePortForward = enablePortForward;
|
||||||
@@ -389,7 +439,9 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param enableSSL
|
* @param enableSSL
|
||||||
|
* @deprecated use {@link #setBaseUrl(String)} and {$link #setForceBaseUrl(boolean)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setEnableSSL(boolean enableSSL)
|
public void setEnableSSL(boolean enableSSL)
|
||||||
{
|
{
|
||||||
this.enableSSL = enableSSL;
|
this.enableSSL = enableSSL;
|
||||||
@@ -399,8 +451,22 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param forwardPort
|
* @param forceBaseUrl
|
||||||
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
|
public void setForceBaseUrl(boolean forceBaseUrl)
|
||||||
|
{
|
||||||
|
this.forceBaseUrl = forceBaseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param forwardPort
|
||||||
|
* @deprecated use {@link #setBaseUrl(String)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setForwardPort(int forwardPort)
|
public void setForwardPort(int forwardPort)
|
||||||
{
|
{
|
||||||
this.forwardPort = forwardPort;
|
this.forwardPort = forwardPort;
|
||||||
@@ -455,7 +521,9 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param sslPort
|
* @param sslPort
|
||||||
|
* @deprecated use {@link #setBaseUrl(String)} and {$link #setForceBaseUrl(boolean)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setSslPort(int sslPort)
|
public void setSslPort(int sslPort)
|
||||||
{
|
{
|
||||||
this.sslPort = sslPort;
|
this.sslPort = sslPort;
|
||||||
@@ -473,10 +541,19 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
@XmlJavaTypeAdapter(XmlSetStringAdapter.class)
|
@XmlJavaTypeAdapter(XmlSetStringAdapter.class)
|
||||||
private Set<String> adminUsers;
|
private Set<String> adminUsers;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
@XmlElement(name = "base-url")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private boolean enableProxy = false;
|
private boolean enableProxy = false;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
@XmlElement(name = "force-base-url")
|
||||||
|
private boolean forceBaseUrl;
|
||||||
|
|
||||||
|
/** @deprecated use {@link $baseUrl} */
|
||||||
|
@Deprecated
|
||||||
private int forwardPort = 80;
|
private int forwardPort = 80;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
@@ -492,13 +569,16 @@ public class ScmConfiguration implements ListenerSupport<ConfigChangedListener>
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
private String servername = "localhost";
|
private String servername = "localhost";
|
||||||
|
|
||||||
/** Field description */
|
/** @deprecated use {@link $baseUrl} and {$link $foreceBaseUrl} */
|
||||||
|
@Deprecated
|
||||||
private boolean enableSSL = false;
|
private boolean enableSSL = false;
|
||||||
|
|
||||||
/** Field description */
|
/** @deprecated use {@link $baseUrl} */
|
||||||
|
@Deprecated
|
||||||
private boolean enablePortForward = false;
|
private boolean enablePortForward = false;
|
||||||
|
|
||||||
/** Field description */
|
/** @deprecated use {@link $baseUrl} and {$link $foreceBaseUrl} */
|
||||||
|
@Deprecated
|
||||||
private int sslPort = 8181;
|
private int sslPort = 8181;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
@@ -83,6 +83,29 @@ public class HttpUtil
|
|||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param configuration
|
||||||
|
* @param path
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @since 1.5
|
||||||
|
*/
|
||||||
|
public static String getCompleteUrl(ScmConfiguration configuration,
|
||||||
|
String path)
|
||||||
|
{
|
||||||
|
String url = configuration.getBaseUrl();
|
||||||
|
|
||||||
|
if (url.endsWith("/") && path.startsWith("/"))
|
||||||
|
{
|
||||||
|
url = url.substring(0, url.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
return url.concat(path);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -91,7 +114,9 @@ public class HttpUtil
|
|||||||
* @param request
|
* @param request
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
* @deprecated use {@link #getCompleteUrl(sonia.scm.config.ScmConfiguration, java.lang.String)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getServerPort(ScmConfiguration configuration,
|
public static int getServerPort(ScmConfiguration configuration,
|
||||||
HttpServletRequest request)
|
HttpServletRequest request)
|
||||||
{
|
{
|
||||||
@@ -137,6 +162,6 @@ public class HttpUtil
|
|||||||
*/
|
*/
|
||||||
public static String getStrippedURI(HttpServletRequest request, String uri)
|
public static String getStrippedURI(HttpServletRequest request, String uri)
|
||||||
{
|
{
|
||||||
return request.getRequestURI().substring(request.getContextPath().length());
|
return uri.substring(request.getContextPath().length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ import sonia.scm.cache.CacheManager;
|
|||||||
import sonia.scm.cache.EhCacheManager;
|
import sonia.scm.cache.EhCacheManager;
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.filter.AdminSecurityFilter;
|
import sonia.scm.filter.AdminSecurityFilter;
|
||||||
|
import sonia.scm.filter.BaseUrlFilter;
|
||||||
import sonia.scm.filter.GZipFilter;
|
import sonia.scm.filter.GZipFilter;
|
||||||
import sonia.scm.filter.SSLFilter;
|
|
||||||
import sonia.scm.filter.SecurityFilter;
|
import sonia.scm.filter.SecurityFilter;
|
||||||
import sonia.scm.group.GroupManager;
|
import sonia.scm.group.GroupManager;
|
||||||
import sonia.scm.group.xml.XmlGroupManager;
|
import sonia.scm.group.xml.XmlGroupManager;
|
||||||
@@ -225,7 +225,7 @@ public class ScmServletModule extends ServletModule
|
|||||||
* filter(PATTERN_PAGE,
|
* filter(PATTERN_PAGE,
|
||||||
* PATTERN_STATIC_RESOURCES).through(StaticResourceFilter.class);
|
* PATTERN_STATIC_RESOURCES).through(StaticResourceFilter.class);
|
||||||
*/
|
*/
|
||||||
filter(PATTERN_ALL).through(SSLFilter.class);
|
filter(PATTERN_ALL).through(BaseUrlFilter.class);
|
||||||
filterRegex(RESOURCE_REGEX).through(GZipFilter.class);
|
filterRegex(RESOURCE_REGEX).through(GZipFilter.class);
|
||||||
filter(PATTERN_RESTAPI, PATTERN_DEBUG).through(SecurityFilter.class);
|
filter(PATTERN_RESTAPI, PATTERN_DEBUG).through(SecurityFilter.class);
|
||||||
filter(PATTERN_CONFIG, PATTERN_ADMIN).through(AdminSecurityFilter.class);
|
filter(PATTERN_CONFIG, PATTERN_ADMIN).through(AdminSecurityFilter.class);
|
||||||
|
|||||||
@@ -263,22 +263,10 @@ public class RepositoryResource
|
|||||||
|
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
{
|
{
|
||||||
HttpServletRequest request = requestProvider.get();
|
String url = handler.createResourcePath(repository);
|
||||||
StringBuilder url = new StringBuilder(request.getScheme());
|
|
||||||
|
|
||||||
url.append("://").append(configuration.getServername());
|
url = HttpUtil.getCompleteUrl(configuration, url);
|
||||||
url.append(":").append(HttpUtil.getServerPort(configuration, request));
|
repository.setUrl(url);
|
||||||
|
|
||||||
String ctxPath = request.getContextPath();
|
|
||||||
|
|
||||||
if (ctxPath.endsWith("/"))
|
|
||||||
{
|
|
||||||
ctxPath = ctxPath.substring(0, ctxPath.length() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
url.append(ctxPath);
|
|
||||||
url.append(handler.createResourcePath(repository));
|
|
||||||
repository.setUrl(url.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ import com.google.inject.Inject;
|
|||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
|
import sonia.scm.util.HttpUtil;
|
||||||
|
import sonia.scm.util.Util;
|
||||||
import sonia.scm.web.filter.HttpFilter;
|
import sonia.scm.web.filter.HttpFilter;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
@@ -55,7 +57,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SSLFilter extends HttpFilter
|
public class BaseUrlFilter extends HttpFilter
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +67,7 @@ public class SSLFilter extends HttpFilter
|
|||||||
* @param configuration
|
* @param configuration
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public SSLFilter(ScmConfiguration configuration)
|
public BaseUrlFilter(ScmConfiguration configuration)
|
||||||
{
|
{
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
@@ -88,20 +90,59 @@ public class SSLFilter extends HttpFilter
|
|||||||
HttpServletResponse response, FilterChain chain)
|
HttpServletResponse response, FilterChain chain)
|
||||||
throws IOException, ServletException
|
throws IOException, ServletException
|
||||||
{
|
{
|
||||||
if (request.isSecure() ||!configuration.isEnableSSL())
|
if (Util.isEmpty(configuration.getBaseUrl()))
|
||||||
|
{
|
||||||
|
configuration.setBaseUrl(createDefaultBaseUrl(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!configuration.isForceBaseUrl() || isBaseUrl(request))
|
||||||
{
|
{
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StringBuilder url = new StringBuilder("https://");
|
String url = HttpUtil.getCompleteUrl(configuration,
|
||||||
|
HttpUtil.getStrippedURI(request));
|
||||||
|
|
||||||
url.append(request.getServerName()).append(":");
|
response.sendRedirect(url);
|
||||||
url.append(configuration.getSslPort()).append(request.getRequestURI());
|
|
||||||
response.sendRedirect(url.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String createDefaultBaseUrl(HttpServletRequest request)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder(request.getScheme());
|
||||||
|
|
||||||
|
sb.append("://").append(request.getServerName()).append(":");
|
||||||
|
sb.append(String.valueOf(request.getServerPort()));
|
||||||
|
sb.append(request.getContextPath());
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isBaseUrl(HttpServletRequest request)
|
||||||
|
{
|
||||||
|
return request.getRequestURL().toString().startsWith(
|
||||||
|
configuration.getBaseUrl());
|
||||||
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
@@ -40,7 +40,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import sonia.scm.SCMContext;
|
import sonia.scm.SCMContext;
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.util.HttpUtil;
|
|
||||||
import sonia.scm.util.IOUtil;
|
import sonia.scm.util.IOUtil;
|
||||||
import sonia.scm.util.SystemUtil;
|
import sonia.scm.util.SystemUtil;
|
||||||
import sonia.scm.util.Util;
|
import sonia.scm.util.Util;
|
||||||
@@ -211,7 +210,8 @@ public class DefaultCGIExecutor extends AbstractCGIExecutor
|
|||||||
private EnvList createEnvironment()
|
private EnvList createEnvironment()
|
||||||
{
|
{
|
||||||
String pathInfo = request.getPathInfo();
|
String pathInfo = request.getPathInfo();
|
||||||
int serverPort = HttpUtil.getServerPort(configuration, request);
|
|
||||||
|
// int serverPort = HttpUtil.getServerPort(configuration, request);
|
||||||
String scriptName = request.getRequestURI().substring(0,
|
String scriptName = request.getRequestURI().substring(0,
|
||||||
request.getRequestURI().length() - pathInfo.length());
|
request.getRequestURI().length() - pathInfo.length());
|
||||||
String scriptPath = context.getRealPath(scriptName);
|
String scriptPath = context.getRealPath(scriptName);
|
||||||
@@ -260,7 +260,8 @@ public class DefaultCGIExecutor extends AbstractCGIExecutor
|
|||||||
env.set(ENV_SCRIPT_NAME, scriptName);
|
env.set(ENV_SCRIPT_NAME, scriptName);
|
||||||
env.set(ENV_SCRIPT_FILENAME, scriptPath);
|
env.set(ENV_SCRIPT_FILENAME, scriptPath);
|
||||||
env.set(ENV_SERVER_NAME, Util.nonNull(request.getServerName()));
|
env.set(ENV_SERVER_NAME, Util.nonNull(request.getServerName()));
|
||||||
env.set(ENV_SERVER_PORT, Integer.toString(serverPort));
|
|
||||||
|
// env.set(ENV_SERVER_PORT, Integer.toString(serverPort));
|
||||||
env.set(ENV_SERVER_PROTOCOL, Util.nonNull(request.getProtocol()));
|
env.set(ENV_SERVER_PROTOCOL, Util.nonNull(request.getProtocol()));
|
||||||
env.set(
|
env.set(
|
||||||
ENV_SERVER_SOFTWARE,
|
ENV_SERVER_SOFTWARE,
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
enableProxyText: 'Enable Proxy',
|
enableProxyText: 'Enable Proxy',
|
||||||
proxyServerText: 'Proxy Server',
|
proxyServerText: 'Proxy Server',
|
||||||
proxyPortText: 'Proxy Port',
|
proxyPortText: 'Proxy Port',
|
||||||
|
baseUrlText: 'Base Url',
|
||||||
|
forceBaseUrlText: 'Force Base Url',
|
||||||
|
|
||||||
|
|
||||||
// help
|
// help
|
||||||
@@ -74,6 +76,8 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
enableProxyHelpText: 'Enable Proxy',
|
enableProxyHelpText: 'Enable Proxy',
|
||||||
proxyServerHelpText: 'The proxy server',
|
proxyServerHelpText: 'The proxy server',
|
||||||
proxyPortHelpText: 'The proxy port',
|
proxyPortHelpText: 'The proxy port',
|
||||||
|
baseUrlHelpText: 'The url of the application (with context path) i.e. http://localhost:8080/scm',
|
||||||
|
forceBaseUrlHelpText: 'Redirects to the base url if the request comes from a other url',
|
||||||
|
|
||||||
|
|
||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
@@ -84,35 +88,22 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
title: this.titleText,
|
title: this.titleText,
|
||||||
items: [{
|
items: [{
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
fieldLabel: this.servnameText,
|
fieldLabel: this.baseUrlText,
|
||||||
name: 'servername',
|
name: 'base-url',
|
||||||
helpText: this.servernameHelpText,
|
helpText: this.baseUrlHelpText,
|
||||||
allowBlank: false
|
allowBlank: false
|
||||||
|
},{
|
||||||
|
xtype: 'checkbox',
|
||||||
|
fieldLabel: this.forceBaseUrlText,
|
||||||
|
name: 'force-base-url',
|
||||||
|
inputValue: 'true',
|
||||||
|
helpText: this.forceBaseUrlHelpText
|
||||||
},{
|
},{
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
fieldLabel: this.dateFormatText,
|
fieldLabel: this.dateFormatText,
|
||||||
name: 'dateFormat',
|
name: 'dateFormat',
|
||||||
helpText: this.dateFormatHelpText,
|
helpText: this.dateFormatHelpText,
|
||||||
allowBlank: false
|
allowBlank: false
|
||||||
},{
|
|
||||||
xtype: 'checkbox',
|
|
||||||
fieldLabel: this.enableForwardingText,
|
|
||||||
name: 'enablePortForward',
|
|
||||||
inputValue: 'true',
|
|
||||||
helpText: this.enableForwardingHelpText,
|
|
||||||
listeners: {
|
|
||||||
check: function(){
|
|
||||||
Ext.getCmp('serverport').setDisabled( ! this.checked );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
id: 'serverport',
|
|
||||||
xtype: 'numberfield',
|
|
||||||
fieldLabel: this.forwardPortText,
|
|
||||||
name: 'forwardPort',
|
|
||||||
disabled: true,
|
|
||||||
allowBlank: false,
|
|
||||||
helpText: this.forwardPortHelpText
|
|
||||||
},{
|
},{
|
||||||
xtype: 'textfield',
|
xtype: 'textfield',
|
||||||
fieldLabel: this.pluginRepositoryText,
|
fieldLabel: this.pluginRepositoryText,
|
||||||
@@ -126,25 +117,6 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
name: 'anonymousAccessEnabled',
|
name: 'anonymousAccessEnabled',
|
||||||
inputValue: 'true',
|
inputValue: 'true',
|
||||||
helpText: this.allowAnonymousAccessHelpText
|
helpText: this.allowAnonymousAccessHelpText
|
||||||
},{
|
|
||||||
xtype: 'checkbox',
|
|
||||||
fieldLabel: this.enableSSLText,
|
|
||||||
name: 'enableSSL',
|
|
||||||
inputValue: 'true',
|
|
||||||
helpText: this.enableSSLHelpText,
|
|
||||||
listeners: {
|
|
||||||
check: function(){
|
|
||||||
Ext.getCmp('sslPort').setDisabled( ! this.checked );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
id: 'sslPort',
|
|
||||||
xtype: 'numberfield',
|
|
||||||
fieldLabel: this.sslPortText,
|
|
||||||
name: 'sslPort',
|
|
||||||
disabled: true,
|
|
||||||
allowBlank: false,
|
|
||||||
helpText: this.sslPortHelpText
|
|
||||||
},{
|
},{
|
||||||
xtype: 'checkbox',
|
xtype: 'checkbox',
|
||||||
fieldLabel: this.enableProxyText,
|
fieldLabel: this.enableProxyText,
|
||||||
@@ -188,12 +160,6 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
}],
|
}],
|
||||||
|
|
||||||
onSubmit: function(values){
|
onSubmit: function(values){
|
||||||
if ( ! values.enableSSL ){
|
|
||||||
values.sslPort = Ext.getCmp('sslPort').getValue();
|
|
||||||
}
|
|
||||||
if ( ! values.enablePortForward ){
|
|
||||||
values.forwardPort = Ext.getCmp('serverport').getValue();
|
|
||||||
}
|
|
||||||
this.el.mask(this.submitText);
|
this.el.mask(this.submitText);
|
||||||
Ext.Ajax.request({
|
Ext.Ajax.request({
|
||||||
url: restUrl + 'config.json',
|
url: restUrl + 'config.json',
|
||||||
@@ -225,12 +191,6 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
success: function(response){
|
success: function(response){
|
||||||
var obj = Ext.decode(response.responseText);
|
var obj = Ext.decode(response.responseText);
|
||||||
this.load(obj);
|
this.load(obj);
|
||||||
if ( obj.enablePortForward ){
|
|
||||||
Ext.getCmp('serverport').setDisabled(false);
|
|
||||||
}
|
|
||||||
if ( obj.enableSSL ){
|
|
||||||
Ext.getCmp('sslPort').setDisabled(false);
|
|
||||||
}
|
|
||||||
if ( obj.enableProxy ){
|
if ( obj.enableProxy ){
|
||||||
Ext.getCmp('proxyServer').setDisabled(false);
|
Ext.getCmp('proxyServer').setDisabled(false);
|
||||||
Ext.getCmp('proxyPort').setDisabled(false);
|
Ext.getCmp('proxyPort').setDisabled(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user