-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ZEPPELIN-1354] [WIP] Inject Services #1361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
5002a15
0fd9096
1d2b80a
28589fb
3641e5b
da097a7
74adbd4
d855a8b
ebe7ebb
39543de
a2ec2f8
1fd0457
c744e41
0befa1b
85e6572
0a51045
7836b89
639d810
146bf62
acdf249
724cac3
7065f50
ea644c8
25d744e
dff202a
b57ca32
bcd1356
3254490
6139e99
da0ede7
2e6d28f
7e196d5
f556dc4
58dec36
2831c49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we add |
||
|
|
||
| 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 |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * 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.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) { | ||
|
|
||
| webApp.setInitParameter("shiroConfigLocations", | ||
| new File(conf.getShiroPath()).toURI().toString()); | ||
|
|
||
| SecurityUtils.initSecurityManager(conf.getShiroPath()); | ||
| webApp.addFilter(org.apache.shiro.web.servlet.ShiroFilter.class, "/api/*", | ||
| EnumSet.allOf(DispatcherType.class)); | ||
|
|
||
| webApp.addEventListener(new org.apache.shiro.web.env.EnvironmentLoaderListener()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldnt be cleaner to import |
||
|
|
||
| } | ||
|
|
||
| } | ||
| 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); | ||
|
|
||
| } |
There was a problem hiding this comment.
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.