+
{{setting.name}}
@@ -191,7 +192,33 @@ Option
pu-elastic-input-minwidth="180px" ng-model="setting.option.port" ng-disabled="!valueform.$visible" />
+
+
+
+
+
+
+
+
Currently there are no properties and dependencies set for this interpreter
diff --git a/zeppelin-web/src/components/interpreter/interpreter.directive.js b/zeppelin-web/src/components/interpreter/interpreter.directive.js
new file mode 100644
index 00000000000..1cf1ab2d178
--- /dev/null
+++ b/zeppelin-web/src/components/interpreter/interpreter.directive.js
@@ -0,0 +1,28 @@
+/*
+ * Licensed 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.
+ */
+'use strict';
+
+angular.module('zeppelinWebApp').directive('interpreterDirective', function($timeout) {
+ return {
+ restrict: 'A',
+ link: function(scope, element, attr) {
+ if (scope.$last === true) {
+ $timeout(function() {
+ var id = 'ngRenderFinished';
+ scope.$emit(id);
+ });
+ }
+ }
+ };
+});
diff --git a/zeppelin-web/src/index.html b/zeppelin-web/src/index.html
index b23db7a7530..0697dcaa104 100644
--- a/zeppelin-web/src/index.html
+++ b/zeppelin-web/src/index.html
@@ -164,6 +164,7 @@
+
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterOption.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterOption.java
index 7aac7816c5e..2bcc4c69ac0 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterOption.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterOption.java
@@ -17,6 +17,8 @@
package org.apache.zeppelin.interpreter;
+import java.util.List;
+
/**
*
*/
@@ -28,7 +30,8 @@ public class InterpreterOption {
boolean perNoteProcess;
boolean isExistingProcess;
-
+ boolean setPermission;
+ List users;
public boolean isExistingProcess() {
return isExistingProcess;
@@ -46,6 +49,17 @@ public void setHost(String host) {
this.host = host;
}
+ public boolean permissionIsSet() {
+ return setPermission;
+ }
+
+ public void setUserPermission(boolean setPermission) {
+ this.setPermission = setPermission;
+ }
+
+ public List getUsers() {
+ return users;
+ }
public InterpreterOption() {
remote = false;
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
index 308cbb05047..079216c76b9 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
@@ -275,6 +275,19 @@ public Map info() {
return null;
}
+ private boolean hasPermission(String user, List intpUsers) {
+ if (1 > intpUsers.size()) {
+ return true;
+ }
+
+ for (String u: intpUsers) {
+ if (user.trim().equals(u.trim())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
protected Object jobRun() throws Throwable {
String replName = getRequiredReplName();
@@ -285,6 +298,17 @@ protected Object jobRun() throws Throwable {
throw new RuntimeException("Can not find interpreter for " + getRequiredReplName());
}
+ if (this.noteHasUser() && this.noteHasInterpreters()) {
+ InterpreterSetting intp = getInterpreterSettingById(repl.getInterpreterGroup().getId());
+ if (intp != null &&
+ interpreterHasUser(intp) &&
+ isUserAuthorizedToAccessInterpreter(intp.getOption()) == false) {
+ logger.error("{} has no permission for {} ", authenticationInfo.getUser(), repl);
+ return new InterpreterResult(Code.ERROR, authenticationInfo.getUser() +
+ " has no permission for " + getRequiredReplName());
+ }
+ }
+
String script = getScriptBody();
// inject form
if (repl.getFormType() == FormType.NATIVE) {
@@ -339,6 +363,34 @@ protected Object jobRun() throws Throwable {
}
}
+ private boolean noteHasUser() {
+ return this.user != null;
+ }
+
+ private boolean noteHasInterpreters() {
+ return !factory.getInterpreterSettings(note.getId()).isEmpty();
+ }
+
+ private boolean interpreterHasUser(InterpreterSetting intp) {
+ return intp.getOption().permissionIsSet() && intp.getOption().getUsers() != null;
+ }
+
+ private boolean isUserAuthorizedToAccessInterpreter(InterpreterOption intpOpt){
+ return intpOpt.permissionIsSet() &&
+ hasPermission(authenticationInfo.getUser(), intpOpt.getUsers());
+ }
+
+ private InterpreterSetting getInterpreterSettingById(String id) {
+ InterpreterSetting setting = null;
+ for (InterpreterSetting i: factory.getInterpreterSettings(note.getId())) {
+ if (id.startsWith(i.getId())) {
+ setting = i;
+ break;
+ }
+ }
+ return setting;
+ }
+
@Override
protected boolean jobAbort() {
Interpreter repl = getRepl(getRequiredReplName());