|
16 | 16 | */ |
17 | 17 | package org.apache.zeppelin.server; |
18 | 18 |
|
| 19 | +import java.util.Collection; |
19 | 20 | import org.apache.commons.lang.StringUtils; |
| 21 | +import org.apache.shiro.realm.Realm; |
| 22 | +import org.apache.shiro.realm.text.IniRealm; |
20 | 23 | import org.apache.shiro.web.env.EnvironmentLoaderListener; |
| 24 | +import org.apache.shiro.web.mgt.DefaultWebSecurityManager; |
21 | 25 | import org.apache.shiro.web.servlet.ShiroFilter; |
22 | 26 | import org.eclipse.jetty.http.HttpVersion; |
23 | 27 | import org.eclipse.jetty.server.HttpConfiguration; |
@@ -98,6 +102,21 @@ public class ZeppelinServer extends Application { |
98 | 102 |
|
99 | 103 | public ZeppelinServer() throws Exception { |
100 | 104 | ZeppelinConfiguration conf = ZeppelinConfiguration.create(); |
| 105 | + Collection<Realm> realms = ((DefaultWebSecurityManager) org.apache.shiro.SecurityUtils |
| 106 | + .getSecurityManager()).getRealms(); |
| 107 | + if (realms.size() > 1) { |
| 108 | + Boolean isIniRealmEnabled = false; |
| 109 | + for (Object realm : realms) { |
| 110 | + if (realm instanceof IniRealm && ((IniRealm) realm).getIni().get("users") != null) { |
| 111 | + isIniRealmEnabled = true; |
| 112 | + break; |
| 113 | + } |
| 114 | + } |
| 115 | + if (isIniRealmEnabled) { |
| 116 | + throw new Exception("IniRealm/password based auth mechanisms should be exclusive. " |
| 117 | + + "Consider removing [users] block from shiro.ini"); |
| 118 | + } |
| 119 | + } |
101 | 120 |
|
102 | 121 | InterpreterOutput.limit = conf.getInt(ConfVars.ZEPPELIN_INTERPRETER_OUTPUT_LIMIT); |
103 | 122 |
|
|
0 commit comments