zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prabhjyotsi...@apache.org
Subject zeppelin git commit: [ZEPPELIN-3213] Support for KNOXSSO logout url as API
Date Fri, 09 Feb 2018 05:37:57 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.8 a186f5b74 -> 055c6e9a5


[ZEPPELIN-3213] Support for KNOXSSO logout url as API

KNOXSSO logout URL can be an API or it can be a redirect URL, Zeppelin should support both.

[Improvement]

* [ZEPPELIN-3213](https://issues.apache.org/jira/browse/ZEPPELIN-3213)

* 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 <prabhjyotsingh@gmail.com>

Closes #2779 from prabhjyotsingh/ZEPPELIN-3213 and squashes the following commits:

6c89f2427 [Prabhjyot Singh] [ZEPPELIN-3213] Support for KNOXSSO logout url as API

Change-Id: I44e3bb13dc3de9330751236c0b3703a8177200e7
(cherry picked from commit 73d15704bc73f02884f5d6f3348c1c1ceb952a5a)
Signed-off-by: Prabhjyot Singh <prabhjyotsingh@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/055c6e9a
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/055c6e9a
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/055c6e9a

Branch: refs/heads/branch-0.8
Commit: 055c6e9a5bbdb3a94c1f69568da25f740dad37ff
Parents: a186f5b
Author: Prabhjyot Singh <prabhjyotsingh@gmail.com>
Authored: Thu Feb 8 12:44:11 2018 +0530
Committer: Prabhjyot Singh <prabhjyotsingh@gmail.com>
Committed: Fri Feb 9 11:07:49 2018 +0530

----------------------------------------------------------------------
 conf/shiro.ini.template                                   |  1 +
 .../java/org/apache/zeppelin/realm/jwt/KnoxJwtRealm.java  |  9 +++++++++
 .../main/java/org/apache/zeppelin/rest/LoginRestApi.java  |  1 +
 zeppelin-web/src/components/navbar/navbar.controller.js   | 10 +++++++++-
 4 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/055c6e9a/conf/shiro.ini.template
----------------------------------------------------------------------
diff --git a/conf/shiro.ini.template b/conf/shiro.ini.template
index 81b31a2..9397025 100644
--- a/conf/shiro.ini.template
+++ b/conf/shiro.ini.template
@@ -61,6 +61,7 @@ user3 = password4, role2
 #knoxJwtRealm.providerUrl = https://domain.example.com/
 #knoxJwtRealm.login = gateway/knoxsso/knoxauth/login.html
 #knoxJwtRealm.logout = gateway/knoxssout/api/v1/webssout
+#knoxJwtRealm.logoutAPI = true
 #knoxJwtRealm.redirectParam = originalUrl
 #knoxJwtRealm.cookieName = hadoop-jwt
 #knoxJwtRealm.publicKeyPath = /etc/zeppelin/conf/knox-sso.pem

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/055c6e9a/zeppelin-server/src/main/java/org/apache/zeppelin/realm/jwt/KnoxJwtRealm.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/realm/jwt/KnoxJwtRealm.java
b/zeppelin-server/src/main/java/org/apache/zeppelin/realm/jwt/KnoxJwtRealm.java
index c3e9b77..a903e6e 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/realm/jwt/KnoxJwtRealm.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/realm/jwt/KnoxJwtRealm.java
@@ -60,6 +60,7 @@ public class KnoxJwtRealm extends AuthorizingRealm {
   private String publicKeyPath;
   private String login;
   private String logout;
+  private Boolean logoutAPI;
 
   private String principalMapping;
   private String groupPrincipalMapping;
@@ -270,6 +271,14 @@ public class KnoxJwtRealm extends AuthorizingRealm {
     this.logout = logout;
   }
 
+  public Boolean getLogoutAPI() {
+    return logoutAPI;
+  }
+
+  public void setLogoutAPI(Boolean logoutAPI) {
+    this.logoutAPI = logoutAPI;
+  }
+
   public String getPrincipalMapping() {
     return principalMapping;
   }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/055c6e9a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java
index 3a084cf..b590bdb 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/LoginRestApi.java
@@ -211,6 +211,7 @@ public class LoginRestApi {
       KnoxJwtRealm knoxJwtRealm = getJTWRealm();
       Map<String, String> data = new HashMap<>();
       data.put("redirectURL", constructKnoxUrl(knoxJwtRealm, knoxJwtRealm.getLogout()));
+      data.put("isLogoutAPI", knoxJwtRealm.getLogoutAPI().toString());
       response = new JsonResponse(Status.UNAUTHORIZED, "", data);
     } else {
       response = new JsonResponse(Status.UNAUTHORIZED, "", "");

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/055c6e9a/zeppelin-web/src/components/navbar/navbar.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/navbar/navbar.controller.js b/zeppelin-web/src/components/navbar/navbar.controller.js
index 7d7fada..139328e 100644
--- a/zeppelin-web/src/components/navbar/navbar.controller.js
+++ b/zeppelin-web/src/components/navbar/navbar.controller.js
@@ -93,7 +93,15 @@ function NavCtrl ($scope, $rootScope, $http, $routeParams, $location,
       if (response.data) {
         let res = angular.fromJson(response.data).body
         if (res['redirectURL']) {
-          window.location.href = res['redirectURL'] + window.location.href
+          if (res['isLogoutAPI'] === 'true') {
+            $http.get(res['redirectURL']).then(function () {
+            }, function () {
+              window.location = baseUrlSrv.getBase()
+            })
+          } else {
+            window.location.href = res['redirectURL'] + window.location.href
+          }
+          return undefined
         }
       }
 


Mime
View raw message