Repository: zeppelin Updated Branches: refs/heads/branch-0.7 57f14bc97 -> 2b82aec52
[ZEPPELIN-2152] Added proxy config support in Helium bundle factory Proxy configuration implementation in Helium bundle factory. Used by Node, NPM and YarnPkg installers. [Improvement] * https://issues.apache.org/jira/browse/ZEPPELIN-2152 Trigger Helium plugins behind proxy * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Nelson Costa <[email protected]> Closes #2363 from necosta/zeppelin2152 and squashes the following commits: f681e73 [Nelson Costa] [ZEPPELIN-2152] Added documentation 5e29cca [Nelson Costa] [ZEPPELIN-2152] Fixed format issues f55e6e2 [Nelson Costa] [ZEPPELIN-2152] Fixed bug in secure/insecure proxy. Added proxy for HeliumOnlineRegistry d9a086a [Nelson Costa] [ZEPPELIN-2152] Added proxy config support in Helium bundle factory (cherry picked from commit 87480056a0b10effaf5556d000f8d0c5186848d0) Signed-off-by: Lee moon soo <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/2b82aec5 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/2b82aec5 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/2b82aec5 Branch: refs/heads/branch-0.7 Commit: 2b82aec5250aa3a05626e1e6d3d87c257f46e19d Parents: 57f14bc Author: Nelson Costa <[email protected]> Authored: Wed May 24 17:03:53 2017 +0100 Committer: Lee moon soo <[email protected]> Committed: Sun May 28 10:58:00 2017 +0900 ---------------------------------------------------------------------- docs/_includes/themes/zeppelin/_navigation.html | 1 + docs/index.md | 1 + docs/security/helium_authorization.md | 28 +++++++++ .../helium/HeliumVisualizationFactory.java | 60 ++++++++++++++++++-- 4 files changed, 84 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/2b82aec5/docs/_includes/themes/zeppelin/_navigation.html ---------------------------------------------------------------------- diff --git a/docs/_includes/themes/zeppelin/_navigation.html b/docs/_includes/themes/zeppelin/_navigation.html index 401c691..a53036b 100644 --- a/docs/_includes/themes/zeppelin/_navigation.html +++ b/docs/_includes/themes/zeppelin/_navigation.html @@ -114,6 +114,7 @@ <li><a href="{{BASE_PATH}}/security/shiroauthentication.html">Shiro Authentication</a></li> <li><a href="{{BASE_PATH}}/security/notebook_authorization.html">Notebook Authorization</a></li> <li><a href="{{BASE_PATH}}/security/datasource_authorization.html">Data Source Authorization</a></li> + <li><a href="{{BASE_PATH}}/security/helium_authorization.html">Helium Authorization</a></li> <li role="separator" class="divider"></li> <li class="title"><span><b>Advanced</b><span></li> <li><a href="{{BASE_PATH}}/install/virtual_machine.html">Zeppelin on Vagrant VM</a></li> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/2b82aec5/docs/index.md ---------------------------------------------------------------------- diff --git a/docs/index.md b/docs/index.md index 543242a..b7cf8db 100644 --- a/docs/index.md +++ b/docs/index.md @@ -172,6 +172,7 @@ Join to our [Mailing list](https://zeppelin.apache.org/community.html) and repor * [Shiro Authentication](./security/shiroauthentication.html) * [Notebook Authorization](./security/notebook_authorization.html) * [Data Source Authorization](./security/datasource_authorization.html) + * [Helium Authorization](./security/helium_authorization.html) * Advanced * [Apache Zeppelin on Vagrant VM](./install/virtual_machine.html) * [Zeppelin on Spark Cluster Mode (Standalone via Docker)](./install/spark_cluster_mode.html#spark-standalone-mode) http://git-wip-us.apache.org/repos/asf/zeppelin/blob/2b82aec5/docs/security/helium_authorization.md ---------------------------------------------------------------------- diff --git a/docs/security/helium_authorization.md b/docs/security/helium_authorization.md new file mode 100644 index 0000000..fdfb435 --- /dev/null +++ b/docs/security/helium_authorization.md @@ -0,0 +1,28 @@ +--- +layout: page +title: "Helium Authorization in Apache Zeppelin" +description: "Apache Zeppelin supports Helium plugins which fetch required installer packages from remote registry/repositories" +group: security +--- +<!-- +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +{% include JB/setup %} + +# Helium Authorization in Apache Zeppelin + +<div id="toc"></div> + +## How to configure proxies? + +Set **http_proxy** and **https_proxy** env variables to allow connection to npm registry behind a corporate firewall. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zeppelin/blob/2b82aec5/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumVisualizationFactory.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumVisualizationFactory.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumVisualizationFactory.java index 9f63bd9..d185c79 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumVisualizationFactory.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumVisualizationFactory.java @@ -21,6 +21,7 @@ import com.google.common.base.Charsets; import com.google.common.io.Resources; import com.google.gson.Gson; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Appender; import org.apache.log4j.PatternLayout; import org.apache.log4j.WriterAppender; @@ -30,6 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; +import java.net.URI; import java.net.URL; import java.util.*; @@ -52,6 +54,7 @@ public class HeliumVisualizationFactory { private ZeppelinConfiguration conf; private File tabledataModulePath; private File visualizationModulePath; + private String defaultNodeRegistryUrl; private String defaultNpmRegistryUrl; private Gson gson; private boolean nodeAndNpmInstalled = false; @@ -76,6 +79,7 @@ public class HeliumVisualizationFactory { File moduleDownloadPath) throws TaskRunnerException { this.workingDirectory = new File(moduleDownloadPath, "vis"); this.conf = conf; + this.defaultNodeRegistryUrl = "https://nodejs.org/dist/"; this.defaultNpmRegistryUrl = conf.getHeliumNpmRegistry(); File installDirectory = workingDirectory; @@ -91,11 +95,13 @@ public class HeliumVisualizationFactory { return; } try { - NPMInstaller npmInstaller = frontEndPluginFactory.getNPMInstaller(getProxyConfig()); + NPMInstaller npmInstaller = frontEndPluginFactory + .getNPMInstaller(getProxyConfig(isSecure(defaultNpmRegistryUrl))); npmInstaller.setNpmVersion(NPM_VERSION); npmInstaller.install(); - NodeInstaller nodeInstaller = frontEndPluginFactory.getNodeInstaller(getProxyConfig()); + NodeInstaller nodeInstaller = frontEndPluginFactory + .getNodeInstaller(getProxyConfig(isSecure(defaultNodeRegistryUrl))); nodeInstaller.setNodeVersion(NODE_VERSION); nodeInstaller.install(); configureLogger(); @@ -105,11 +111,52 @@ public class HeliumVisualizationFactory { } } - private ProxyConfig getProxyConfig() { - List<ProxyConfig.Proxy> proxy = new LinkedList<>(); - return new ProxyConfig(proxy); + + private ProxyConfig getProxyConfig(boolean isSecure) { + List<ProxyConfig.Proxy> proxies = new LinkedList<>(); + + String httpProxy = StringUtils.isBlank(System.getenv("http_proxy")) ? + System.getenv("HTTP_PROXY") : System.getenv("http_proxy"); + + String httpsProxy = StringUtils.isBlank(System.getenv("https_proxy")) ? + System.getenv("HTTPS_PROXY") : System.getenv("https_proxy"); + + try { + if (isSecure) + proxies.add(generateProxy("secure", new URI(httpsProxy))); + else proxies.add(generateProxy("insecure", new URI(httpProxy))); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + } + return new ProxyConfig(proxies); } + private ProxyConfig.Proxy generateProxy(String proxyId, URI uri) { + + String protocol = uri.getScheme(); + String host = uri.getHost(); + int port = uri.getPort() <= 0 ? 80 : uri.getPort(); + + String username = null, password = null; + if (uri.getUserInfo() != null) { + String[] authority = uri.getUserInfo().split(":"); + if (authority.length == 2) { + username = authority[0]; + password = authority[1]; + } else if (authority.length == 1) { + username = authority[0]; + } + } + String nonProxyHosts = StringUtils.isBlank(System.getenv("no_proxy")) ? + System.getenv("NO_PROXY") : System.getenv("no_proxy"); + return new ProxyConfig.Proxy(proxyId, protocol, host, port, username, password, nonProxyHosts); + } + + private boolean isSecure(String url) { + return url.toLowerCase().startsWith("https"); + } + + public File bundle(List<HeliumPackage> pkgs) throws IOException { return bundle(pkgs, false); } @@ -380,7 +427,8 @@ public class HeliumVisualizationFactory { private void npmCommand(String args, Map<String, String> env) throws TaskRunnerException { installNodeAndNpm(); - NpmRunner npm = frontEndPluginFactory.getNpmRunner(getProxyConfig(), defaultNpmRegistryUrl); + NpmRunner npm = frontEndPluginFactory.getNpmRunner( + getProxyConfig(isSecure(defaultNpmRegistryUrl)), defaultNpmRegistryUrl); npm.execute(args, env); }
