-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
5002a15
add guice dependencies
echarles 0fd9096
Merge branch 'master' into inject-services
echarles 1d2b80a
Initial working implemenation of service injection for WebSecurity an…
echarles 28589fb
Merge branch 'master' into inject-services
echarles 3641e5b
temporary comment governator - seems to give issues when zeppelin run…
echarles da097a7
Revert change made to zeppelin-web/pom.xml
echarles 74adbd4
Fix format
echarles d855a8b
Merge branch 'master' into inject-services
echarles ebe7ebb
Automatic message for commit of samedi 18 mars 2017, 11:23:13 (UTC+0000)
echarles 39543de
Merge branch 'master' of https://github.com/apache/zeppelin
echarles a2ec2f8
Merge branch 'master' into inject-services
echarles 1fd0457
revert back to scala 2.10
echarles c744e41
Merge branch 'master' into inject-services
echarles 0befa1b
Merge branch 'master' into inject-services
echarles 85e6572
Use com.google.inject.Inject instead of javax.inject.Inject to avoid …
echarles 0a51045
Merge branch 'master' into inject-services
echarles 7836b89
Remove duplicate searchService field
echarles 639d810
Merge branch 'master' into inject-services
echarles 146bf62
merge master
echarles acdf249
Merge branch 'master' into inject-services
echarles 724cac3
Merge branch 'master' into inject-services
echarles 7065f50
fix typo when merging
echarles ea644c8
Merge branch 'master' into inject-services
echarles 25d744e
Align to master change
echarles dff202a
fix compilation issue
echarles b57ca32
fix compilation issue
echarles bcd1356
Merge branch 'master' into inject-services
echarles 3254490
update to master
echarles 6139e99
Fix compilation issue:
echarles da0ede7
fix
echarles 2e6d28f
fix
echarles 7e196d5
Merge branch 'master' into inject-services
echarles f556dc4
Merge branch 'master' into inject-services
echarles 58dec36
Merge branch 'master' into inject-services
echarles 2831c49
Merge branch 'master' into inject-services
echarles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
zeppelin-server/src/main/java/org/apache/zeppelin/inject/ZeppelinModule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
zeppelin-server/src/main/java/org/apache/zeppelin/web/DefaultWebSecurity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } |
32 changes: 32 additions & 0 deletions
32
zeppelin-server/src/main/java/org/apache/zeppelin/web/WebSecurity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.