-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ZEPPELIN-1690] - ZeppelinHubNotebookRepo multy user handling
### What is this PR for? This PR bring multi user handling to ZeppelinHubNotebookRepo. ### What type of PR is it? [Improvement ] ### What is the Jira issue? * [ZEPPELIN-1690](https://issues.apache.org/jira/browse/ZEPPELIN-1690) ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Anthony Corbacho <corbacho.anthony@gmail.com> Closes #1635 from anthonycorbacho/feat/ZeppelinHubRepoMultiUser and squashes the following commits: d9e0036 [Anthony Corbacho] Move code location d8989aa [Anthony Corbacho] Handle invalid subject aef6e00 [Anthony Corbacho] Fix check style edb9e8c [Anthony Corbacho] Desactivate ws :: we will need to refactor this part e884203 [Anthony Corbacho] Refactor :: remove 'async' on every http call dbb8ebd [Anthony Corbacho] Fix test 25f6215 [Anthony Corbacho] pass user token to zeppelinhub rest api handler 674fb93 [Anthony Corbacho] Refactor ZeppelinHub rest API handler - Now takes a token on every http request 3fbfcfa [Anthony Corbacho] Add new login on how user can get his token at runtime a8aeb51 [Anthony Corbacho] add comment in zeppelinhubRealm about saving user session in a singleton map 5931ab6 [Anthony Corbacho] Fix check style 67051a0 [Anthony Corbacho] Add ZeppelinHub instance model e3e5a15 [Anthony Corbacho] Add userTiket in AuthenticationInfo on OnMessage method in notebookServer 7a0c959 [Anthony Corbacho] Add zeppelinhub user session to userSession container after login throght zeppelinhubRealm 0729f51 [Anthony Corbacho] Add zeppelinhub session container
- Loading branch information
1 parent
3389e8c
commit 33e2dab
Showing
7 changed files
with
249 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...n-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/model/Instance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
package org.apache.zeppelin.notebook.repo.zeppelinhub.model; | ||
|
||
/** | ||
* ZeppelinHub Instance structure. | ||
* | ||
*/ | ||
public class Instance { | ||
public int id; | ||
public String name; | ||
public String token; | ||
} |
54 changes: 54 additions & 0 deletions
54
...c/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/model/UserSessionContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
package org.apache.zeppelin.notebook.repo.zeppelinhub.model; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
|
||
/** | ||
* Simple and yet dummy container for zeppelinhub session. | ||
* | ||
*/ | ||
public class UserSessionContainer { | ||
private static class Entity { | ||
public final String userSession; | ||
|
||
Entity(String userSession) { | ||
this.userSession = userSession; | ||
} | ||
} | ||
|
||
private Map<String, Entity> sessions = new ConcurrentHashMap<>(); | ||
|
||
public static final UserSessionContainer instance = new UserSessionContainer(); | ||
|
||
public synchronized String getSession(String principal) { | ||
Entity entry = sessions.get(principal); | ||
if (entry == null) { | ||
return StringUtils.EMPTY; | ||
} | ||
return entry.userSession; | ||
} | ||
|
||
public synchronized String setSession(String principal, String userSession) { | ||
Entity entry = new Entity(userSession); | ||
sessions.put(principal, entry); | ||
return entry.userSession; | ||
} | ||
} |
Oops, something went wrong.