Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5002a15
add guice dependencies
echarles Aug 24, 2016
0fd9096
Merge branch 'master' into inject-services
echarles Aug 25, 2016
1d2b80a
Initial working implemenation of service injection for WebSecurity an…
echarles Aug 25, 2016
28589fb
Merge branch 'master' into inject-services
echarles Aug 25, 2016
3641e5b
temporary comment governator - seems to give issues when zeppelin run…
echarles Aug 25, 2016
da097a7
Revert change made to zeppelin-web/pom.xml
echarles Aug 31, 2016
74adbd4
Fix format
echarles Sep 2, 2016
d855a8b
Merge branch 'master' into inject-services
echarles Sep 2, 2016
ebe7ebb
Automatic message for commit of samedi 18 mars 2017, 11:23:13 (UTC+0000)
echarles Mar 18, 2017
39543de
Merge branch 'master' of https://github.com/apache/zeppelin
echarles Mar 25, 2017
a2ec2f8
Merge branch 'master' into inject-services
echarles Mar 25, 2017
1fd0457
revert back to scala 2.10
echarles Apr 6, 2017
c744e41
Merge branch 'master' into inject-services
echarles Apr 9, 2017
0befa1b
Merge branch 'master' into inject-services
echarles Apr 16, 2017
85e6572
Use com.google.inject.Inject instead of javax.inject.Inject to avoid …
echarles Apr 18, 2017
0a51045
Merge branch 'master' into inject-services
echarles Apr 18, 2017
7836b89
Remove duplicate searchService field
echarles Apr 19, 2017
639d810
Merge branch 'master' into inject-services
echarles Apr 23, 2017
146bf62
merge master
echarles Apr 23, 2017
acdf249
Merge branch 'master' into inject-services
echarles May 3, 2017
724cac3
Merge branch 'master' into inject-services
echarles May 4, 2017
7065f50
fix typo when merging
echarles May 4, 2017
ea644c8
Merge branch 'master' into inject-services
echarles Jun 5, 2017
25d744e
Align to master change
echarles Jun 5, 2017
dff202a
fix compilation issue
echarles Jun 5, 2017
b57ca32
fix compilation issue
echarles Jun 5, 2017
bcd1356
Merge branch 'master' into inject-services
echarles Jul 21, 2017
3254490
update to master
echarles Jul 21, 2017
6139e99
Fix compilation issue:
echarles Jul 21, 2017
da0ede7
fix
echarles Sep 3, 2017
2e6d28f
fix
echarles Sep 3, 2017
7e196d5
Merge branch 'master' into inject-services
echarles Sep 3, 2017
f556dc4
Merge branch 'master' into inject-services
echarles Nov 6, 2017
58dec36
Merge branch 'master' into inject-services
echarles Dec 15, 2017
2831c49
Merge branch 'master' into inject-services
echarles Jan 3, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@
<slf4j.version>1.7.10</slf4j.version>
<log4j.version>1.2.17</log4j.version>
<libthrift.version>0.9.2</libthrift.version>
<governator.version>1.14.2</governator.version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like governator is not used (all import are commented), I think it better to remove it instead of having bunch of commented code.

<gson.version>2.2</gson.version>
<guice.version>4.1.0</guice.version>
<gson-extras.version>0.2.1</gson-extras.version>
<jetty.version>9.2.15.v20160210</jetty.version>
<httpcomponents.core.version>4.4.1</httpcomponents.core.version>
Expand Down Expand Up @@ -203,6 +205,12 @@
<version>${gson.version}</version>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${guice.version}</version>
</dependency>

<dependency>
<groupId>org.danilopianini</groupId>
<artifactId>gson-extras</artifactId>
Expand Down
10 changes: 10 additions & 0 deletions zeppelin-interpreter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,19 @@
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-guice</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${guice.version}</version>
</dependency>

<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@ public boolean getBoolean(String envName, String propertyName, boolean defaultVa
return getBooleanValue(propertyName, defaultValue);
}

public Class<?> getClass(ConfVars c) {
try {
return Class.forName(c.getStringValue());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}

public boolean useSsl() {
return getBoolean(ConfVars.ZEPPELIN_SSL);
}
Expand Down Expand Up @@ -351,6 +359,14 @@ public String getTrustStorePassword() {
}
}

public Class<?> getZeppelinWebSecurityClassname() {
return getClass(ConfVars.ZEPPELIN_WEB_SECURITY_CLASSNAME);
}

public Class<?> getZeppelinSearchServiceClassname() {
return getClass(ConfVars.ZEPPELIN_SEARCH_SERVICE_CLASSNAME);
}

public String getNotebookDir() {
return getString(ConfVars.ZEPPELIN_NOTEBOOK_DIR);
}
Expand Down Expand Up @@ -720,6 +736,11 @@ public static enum ConfVars {
ZEPPELIN_CREDENTIALS_PERSIST("zeppelin.credentials.persist", true),
ZEPPELIN_CREDENTIALS_ENCRYPT_KEY("zeppelin.credentials.encryptKey", null),
ZEPPELIN_WEBSOCKET_MAX_TEXT_MESSAGE_SIZE("zeppelin.websocket.max.text.message.size", "1024000"),
ZEPPELIN_USE_JDBC_ALIAS("zeppelin.use.jdbc.alias", true),
ZEPPELIN_WEB_SECURITY_CLASSNAME("zeppelin.web.security.classname",
"org.apache.zeppelin.web.DefaultWebSecurity"),
ZEPPELIN_SEARCH_SERVICE_CLASSNAME("zeppelin.search.service.classname",
"org.apache.zeppelin.search.LuceneSearch"),
ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED("zeppelin.server.default.dir.allowed", false),
ZEPPELIN_SERVER_XFRAME_OPTIONS("zeppelin.server.xframe.options", "SAMEORIGIN"),
ZEPPELIN_SERVER_JETTY_NAME("zeppelin.server.jetty.name", null),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.zeppelin.inject;

import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.search.SearchService;
import org.apache.zeppelin.server.ZeppelinServer;
import org.apache.zeppelin.web.WebSecurity;

/**
* Guice injection module.
*/
public class ZeppelinModule implements Module {
private ZeppelinConfiguration conf;

public ZeppelinModule(ZeppelinConfiguration conf) {
this.conf = conf;
}

@Override
public void configure(Binder binder) {

binder.bind(WebSecurity.class)
.to((Class<WebSecurity>) conf.getZeppelinWebSecurityClassname());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add Singleton scope here? what do you think?


binder.bind(SearchService.class)
.to((Class<SearchService>) conf.getZeppelinSearchServiceClassname());

binder.requestStaticInjection(ZeppelinServer.class);

}

@Provides
public ZeppelinConfiguration getZeppelinConfiguration() {
return conf;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@
* 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,
* 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.
*/

package org.apache.zeppelin.server;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Inject;

import org.apache.zeppelin.web.WebSecurity;
import org.apache.zeppelin.inject.ZeppelinModule;

import java.io.File;
import java.io.IOException;
import java.util.EnumSet;
Expand Down Expand Up @@ -78,17 +85,26 @@ public class ZeppelinServer extends Application {
public static Server jettyWebServer;
public static NotebookServer notebookWsServer;
public static Helium helium;
public static HeliumApplicationFactory heliumApplicationFactory;
public static Injector injector;
@Inject
private static WebSecurity webSecurity;

private final InterpreterSettingManager interpreterSettingManager;
private SchedulerFactory schedulerFactory;
private InterpreterFactory replFactory;

@Inject
private ZeppelinConfiguration conf;
@Inject
private SearchService noteSearchService;
private NotebookRepoSync notebookRepo;
private NotebookAuthorization notebookAuthorization;
private Credentials credentials;

public ZeppelinServer() throws Exception {
ZeppelinConfiguration conf = ZeppelinConfiguration.create();

injector.injectMembers(this);



Expand Down Expand Up @@ -158,13 +174,16 @@ public ZeppelinServer() throws Exception {

notebook.addNotebookEventListener(heliumApplicationFactory);
notebook.addNotebookEventListener(notebookWsServer.getNotebookInformationListener());

}

public static void main(String[] args) throws InterruptedException {

final ZeppelinConfiguration conf = ZeppelinConfiguration.create();
conf.setProperty("args", args);

injector = Guice.createInjector(new ZeppelinModule(conf));

jettyWebServer = setupJettyServer(conf);

ContextHandlerCollection contexts = new ContextHandlerCollection();
Expand Down Expand Up @@ -330,14 +349,8 @@ private static void setupRestApiContextHandler(WebAppContext webapp,
webapp.setSessionHandler(new SessionHandler());
webapp.addServlet(servletHolder, "/api/*");

String shiroIniPath = conf.getShiroPath();
if (!StringUtils.isBlank(shiroIniPath)) {
webapp.setInitParameter("shiroConfigLocations", new File(shiroIniPath).toURI().toString());
SecurityUtils.setIsEnabled(true);
webapp.addFilter(ShiroFilter.class, "/api/*", EnumSet.allOf(DispatcherType.class))
.setInitParameter("staticSecurityManagerEnabled", "true");
webapp.addEventListener(new EnvironmentLoaderListener());
}
webSecurity.addSecurityFilter(webapp);

}

private static WebAppContext setupWebAppContext(ContextHandlerCollection contexts,
Expand All @@ -363,8 +376,7 @@ private static WebAppContext setupWebAppContext(ContextHandlerCollection context
webApp.addServlet(new ServletHolder(new DefaultServlet()), "/*");
contexts.addHandler(webApp);

webApp.addFilter(new FilterHolder(CorsFilter.class), "/*",
EnumSet.allOf(DispatcherType.class));
webSecurity.addCorFilter(webApp);

webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed",
Boolean.toString(conf.getBoolean(ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED)));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.zeppelin.web;

import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.web.env.EnvironmentLoaderListener;
import org.apache.shiro.web.servlet.ShiroFilter;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.server.CorsFilter;
import org.apache.zeppelin.utils.SecurityUtils;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.webapp.WebAppContext;

import javax.inject.Inject;
import javax.servlet.DispatcherType;
import java.io.File;
import java.util.EnumSet;

/**
* Default implementation of the actions to be taken
* by Zeppelin to secure the Web channel.
*/
public class DefaultWebSecurity implements WebSecurity {

@Inject
private ZeppelinConfiguration conf;

@Override
public void addCorFilter(WebAppContext webApp) {

webApp.addFilter(new FilterHolder(CorsFilter.class), "/*",
EnumSet.allOf(DispatcherType.class));

}

@Override
public void addSecurityFilter(WebAppContext webapp) {

String shiroIniPath = conf.getShiroPath();

if (!StringUtils.isBlank(shiroIniPath)) {
webapp.setInitParameter("shiroConfigLocations", new File(shiroIniPath).toURI().toString());
SecurityUtils.setIsEnabled(true);
webapp.addFilter(ShiroFilter.class, "/api/*", EnumSet.allOf(DispatcherType.class))
.setInitParameter("staticSecurityManagerEnabled", "true");
webapp.addEventListener(new EnvironmentLoaderListener());
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

package org.apache.zeppelin.web;

import org.eclipse.jetty.webapp.WebAppContext;

/**
* Definition of the actions to be taken
* by Zeppelin to secure the Web channel.
*/
public interface WebSecurity {

void addCorFilter(WebAppContext webApp);

void addSecurityFilter(WebAppContext webApp);

}
6 changes: 6 additions & 0 deletions zeppelin-zengine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@
<version>15.0</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>2.0.7</version>
</dependency>

<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
Expand Down