Skip to content

Commit

Permalink
[ZEPPELIN-3655] Add missing roles information to api/notebook/job/ me…
Browse files Browse the repository at this point in the history
…thod

### What is this PR for?
Fix bugs with private access interpreter launched with REST by adding missing roles information to `AuthenticationInfo`.

### What type of PR is it?
Bug Fix

### What is the Jira issue?
[ZEPPELIN-3655](https://issues.apache.org/jira/projects/ZEPPELIN/issues/ZEPPELIN-3655)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: oxygen311 <alex39-09@mail.ru>

Closes #3093 from oxygen311/ZEPPELIN-3655 and squashes the following commits:

aa51ca3 [oxygen311] Add roles info to run paragraph method
407b104 [oxygen311] Change
0444284 [oxygen311] Merge branch 'master' of https://github.com/apache/zeppelin into ZEPPELIN-3655
182dadc [oxygen311] Fix roles info
  • Loading branch information
oxygen311 authored and zjffdu committed Jul 31, 2018
1 parent 76e0027 commit 858cfcd
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -61,6 +61,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -699,10 +700,11 @@ public Response clearAllParagraphOutput(@PathParam("noteId") String noteId)
public Response runNoteJobs(@PathParam("noteId") String noteId,
@QueryParam("waitToFinish") Boolean waitToFinish)
throws IOException, IllegalArgumentException {
boolean blocking = waitToFinish == null ? true : waitToFinish.booleanValue();
boolean blocking = waitToFinish == null || waitToFinish;
LOG.info("run note jobs {} waitToFinish: {}", noteId, blocking);
Note note = notebook.getNote(noteId);
AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
subject.setRoles(new LinkedList<>(SecurityUtils.getAssociatedRoles()));
checkIfNoteIsNotNull(note);
checkIfUserCanRun(noteId, "Insufficient privileges you cannot run job for this note");

Expand Down Expand Up @@ -817,6 +819,7 @@ public Response runParagraph(@PathParam("noteId") String noteId,
handleParagraphParams(message, note, paragraph);

AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
subject.setRoles(new LinkedList<>(SecurityUtils.getAssociatedRoles()));

paragraph.setAuthenticationInfo(subject);
note.persist(subject);
Expand Down Expand Up @@ -859,6 +862,7 @@ public Response runParagraphSynchronously(@PathParam("noteId") String noteId,
}

AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal());
subject.setRoles(new LinkedList<>(SecurityUtils.getAssociatedRoles()));
paragraph.setAuthenticationInfo(subject);

paragraph.run();
Expand Down

0 comments on commit 858cfcd

Please sign in to comment.