Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@
<artifactId>shiro-web</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-config-core</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
9 changes: 9 additions & 0 deletions zeppelin-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<runOrder>alphabetical</runOrder>
</configuration>
</plugin>

<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.zeppelin.search.SearchService;
import org.apache.zeppelin.socket.NotebookServer;
import org.apache.zeppelin.user.Credentials;
import org.apache.zeppelin.utils.SecurityUtils;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
Expand Down Expand Up @@ -238,6 +239,7 @@ private static void setupRestApiContextHandler(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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.ThreadContext;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.zeppelin.conf.ZeppelinConfiguration;

import java.net.InetAddress;
Expand All @@ -34,6 +36,12 @@
*/
public class SecurityUtils {

public static void initSecurityManager(String shiroPath) {
IniSecurityManagerFactory factory = new IniSecurityManagerFactory("file:" + shiroPath);
SecurityManager securityManager = factory.getInstance();
org.apache.shiro.SecurityUtils.setSecurityManager(securityManager);
}

public static Boolean isValidOrigin(String sourceHost, ZeppelinConfiguration conf)
throws UnknownHostException, URISyntaxException {
if (sourceHost == null || sourceHost.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,28 @@ public void testCreateNewButton() throws Exception {
ZeppelinITUtils.sleep(1000, false);
waitForParagraph(1, "READY");

String oldIntpTag = driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText();

collector.checkThat("Paragraph is created above",
driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(),
CoreMatchers.equalTo(StringUtils.EMPTY));
CoreMatchers.not(StringUtils.EMPTY));
setTextOfParagraph(1, " this is above ");


newPara = driver.findElement(By.xpath(getParagraphXPath(2) + "//div[contains(@class,'new-paragraph')][2]"));
action.moveToElement(newPara).click().build().perform();

waitForParagraph(3, "READY");

String lastIntpTag = driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText();

collector.checkThat("Paragraph is created below",
driver.findElement(By.xpath(getParagraphXPath(3) + "//div[contains(@class, 'editor')]")).getText(),
CoreMatchers.equalTo(StringUtils.EMPTY));
CoreMatchers.not(StringUtils.EMPTY));
setTextOfParagraph(3, " this is below ");

collector.checkThat("Compare interpreter name tag", oldIntpTag, CoreMatchers.equalTo(lastIntpTag));

collector.checkThat("The output field of paragraph1 contains",
driver.findElement(By.xpath(getParagraphXPath(1) + "//div[contains(@class, 'editor')]")).getText(),
CoreMatchers.equalTo(" this is above "));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
/**
* Created for org.apache.zeppelin.integration on 13/06/16.
*/
public class AuthenticationIT extends AbstractZeppelinIT {
private static final Logger LOG = LoggerFactory.getLogger(AuthenticationIT.class);
public class ZeppelinShiroAuthenticationIT extends AbstractZeppelinIT {
private static final Logger LOG = LoggerFactory.getLogger(ZeppelinShiroAuthenticationIT.class);

@Rule
public ErrorCollector collector = new ErrorCollector();
Expand Down Expand Up @@ -133,7 +133,7 @@ public void testSimpleAuthentication() throws Exception {
return;
}
try {
AuthenticationIT authenticationIT = new AuthenticationIT();
ZeppelinShiroAuthenticationIT authenticationIT = new ZeppelinShiroAuthenticationIT();
authenticationIT.authenticationUser("admin", "password1");

collector.checkThat("Check is user logged in", true,
Expand All @@ -152,7 +152,7 @@ public void testGroupPermission() throws Exception {
return;
}
try {
AuthenticationIT authenticationIT = new AuthenticationIT();
ZeppelinShiroAuthenticationIT authenticationIT = new ZeppelinShiroAuthenticationIT();
authenticationIT.authenticationUser("finance1", "finance1");
createNewNote();

Expand Down