You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by pr...@apache.org on 2016/06/28 16:08:45 UTC
zeppelin git commit: [ZEPPELIN-1060] validate user before saving
Repository: zeppelin
Updated Branches:
refs/heads/master 7951e6c69 -> c0cee7caf
[ZEPPELIN-1060] validate user before saving
### What is this PR for?
Zeppelin notebook permissions change has an issue while reconfiguring permissions by clearing textbox
### What type of PR is it?
[Bug Fix]
### Todos
* [x] - Validate user list before saving
* [x] - getPermissions from server again before showing popup
### What is the Jira issue?
* [ZEPPELIN-1060](https://issues.apache.org/jira/browse/ZEPPELIN-1060)
### How should this be tested?
1) I log in as user 'admin'
2) I create a notebook 'Untitled Notebbok 1' as user admin
3) I setup permissions of the notebook as owners = admin, readers= admin, writers= admin and click save button
It works file
4) Now I again try to give owners permission to 'All users' by clearing owners field. Since in step-3 owners = admin ; it allows me to save these changes successfully
5) Now I again try to toggle permissions of the notebook. Since in step-4 I cleared owners field, it should allow all users to change permissions. But it is not happening, instead it gives an error box that only User = [] has sufficient permissions
### Questions:
* Does the licenses files need update? n/a
* Is there breaking changes for older versions? n/a
* Does this needs documentation? n/a
Author: Prabhjyot Singh <pr...@gmail.com>
Closes #1080 from prabhjyotsingh/ZEPPELIN-1060 and squashes the following commits:
93aa640 [Prabhjyot Singh] Merge remote-tracking branch 'origin/master' into ZEPPELIN-1060
f735133 [Prabhjyot Singh] validate user before saving
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/c0cee7ca
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/c0cee7ca
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/c0cee7ca
Branch: refs/heads/master
Commit: c0cee7cafd56c0981590c2ce867e92484370334a
Parents: 7951e6c
Author: Prabhjyot Singh <pr...@gmail.com>
Authored: Sat Jun 25 09:18:06 2016 +0530
Committer: Prabhjyot Singh <pr...@gmail.com>
Committed: Tue Jun 28 21:38:35 2016 +0530
----------------------------------------------------------------------
zeppelin-web/src/app/notebook/notebook.controller.js | 15 +++++++++------
.../zeppelin/notebook/NotebookAuthorization.java | 13 +++++++++++++
2 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c0cee7ca/zeppelin-web/src/app/notebook/notebook.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js
index 3a13057..0b93ae9 100644
--- a/zeppelin-web/src/app/notebook/notebook.controller.js
+++ b/zeppelin-web/src/app/notebook/notebook.controller.js
@@ -713,13 +713,16 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl',
$http.put(baseUrlSrv.getRestApiBase() + '/notebook/' + $scope.note.id + '/permissions',
$scope.permissions, {withCredentials: true}).
success(function (data, status, headers, config) {
- console.log('Note permissions %o saved', $scope.permissions);
- BootstrapDialog.alert({
- closable: true,
- title: 'Permissions Saved Successfully!!!',
- message: 'Owners : ' + $scope.permissions.owners + '\n\n' + 'Readers : ' + $scope.permissions.readers + '\n\n' + 'Writers : ' + $scope.permissions.writers
+ getPermissions(function() {
+ console.log('Note permissions %o saved', $scope.permissions);
+ BootstrapDialog.alert({
+ closable: true,
+ title: 'Permissions Saved Successfully!!!',
+ message: 'Owners : ' + $scope.permissions.owners + '\n\n' + 'Readers : ' +
+ $scope.permissions.readers + '\n\n' + 'Writers : ' + $scope.permissions.writers
+ });
+ $scope.showPermissions = false;
});
- $scope.showPermissions = false;
}).
error(function (data, status, headers, config) {
console.log('Error %o %o', status, data.message);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/c0cee7ca/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NotebookAuthorization.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NotebookAuthorization.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NotebookAuthorization.java
index 82f6138..0633906 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NotebookAuthorization.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NotebookAuthorization.java
@@ -102,8 +102,19 @@ public class NotebookAuthorization {
}
}
+ private Set<String> validateUser(Set<String> users) {
+ Set<String> returnUser = new HashSet<>();
+ for (String user : users) {
+ if (!user.trim().isEmpty()) {
+ returnUser.add(user.trim());
+ }
+ }
+ return returnUser;
+ }
+
public void setOwners(String noteId, Set<String> entities) {
Map<String, Set<String>> noteAuthInfo = authInfo.get(noteId);
+ entities = validateUser(entities);
if (noteAuthInfo == null) {
noteAuthInfo = new LinkedHashMap();
noteAuthInfo.put("owners", new LinkedHashSet(entities));
@@ -118,6 +129,7 @@ public class NotebookAuthorization {
public void setReaders(String noteId, Set<String> entities) {
Map<String, Set<String>> noteAuthInfo = authInfo.get(noteId);
+ entities = validateUser(entities);
if (noteAuthInfo == null) {
noteAuthInfo = new LinkedHashMap();
noteAuthInfo.put("owners", new LinkedHashSet());
@@ -132,6 +144,7 @@ public class NotebookAuthorization {
public void setWriters(String noteId, Set<String> entities) {
Map<String, Set<String>> noteAuthInfo = authInfo.get(noteId);
+ entities = validateUser(entities);
if (noteAuthInfo == null) {
noteAuthInfo = new LinkedHashMap();
noteAuthInfo.put("owners", new LinkedHashSet());