diff --git a/pom.xml b/pom.xml index a035c6db786..ccd04efd40e 100755 --- a/pom.xml +++ b/pom.xml @@ -211,6 +211,11 @@ shiro-web 1.2.3 + + org.apache.shiro + shiro-config-core + 1.2.3 + diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java index 7412611532b..0ff0dc6ac63 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java @@ -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; @@ -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)); diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/utils/SecurityUtils.java b/zeppelin-server/src/main/java/org/apache/zeppelin/utils/SecurityUtils.java index 4de45731a76..f9e5929a882 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/utils/SecurityUtils.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/utils/SecurityUtils.java @@ -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; @@ -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()) { diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java index a76706b9ff3..7312eff0208 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/integration/ParagraphActionsIT.java @@ -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 ")); @@ -331,6 +338,12 @@ public void testTitleButton() throws Exception { String xpathToShowTitle=getParagraphXPath(1) + "//ul/li/a[@ng-click='showTitle()']"; String xpathToHideTitle=getParagraphXPath(1) + "//ul/li/a[@ng-click='hideTitle()']"; + LOG.info("1clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed()); + + sleep(1000, false); + + + LOG.info("2clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed()); collector.checkThat("Before Show Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("")); @@ -338,17 +351,17 @@ public void testTitleButton() throws Exception { collector.checkThat("Before Show Title : The title option in option panel of paragraph is labeled as ", driver.findElement(By.xpath(xpathToShowTitle)).getText(), CoreMatchers.equalTo("Show title")); - + LOG.info("3clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed()); driver.findElement(By.xpath(xpathToShowTitle)).click(); collector.checkThat("After Show Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(), CoreMatchers.equalTo("Untitled")); - + LOG.info("4clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed()); driver.findElement(By.xpath(xpathToSettingIcon)).click(); collector.checkThat("After Show Title : The title option in option panel of paragraph is labeled as", driver.findElement(By.xpath(xpathToHideTitle)).getText(), CoreMatchers.equalTo("Hide title")); - + LOG.info("5clover is displaded {}", driver.findElement(By.xpath(xpathToTitle)).isDisplayed()); driver.findElement(By.xpath(xpathToHideTitle)).click(); collector.checkThat("After Hide Title : The title field contains", driver.findElement(By.xpath(xpathToTitle)).getText(),