[Pki-devel] [PATCH] 569 Customized TPS UI menu based on user roles.

Endi Sukma Dewata edewata at redhat.com
Sat Apr 11 00:24:48 UTC 2015


The TPS UI has been modified to customize the navigation menu
based on the roles of the user currently logged in. TPS agents
do not have access to user, group, config, authenticator,
connector, profile mapping, audit, and self test services, so
the corresponding menu items will not be visible. TPS admins
have access to all menu items.

https://fedorahosted.org/pki/ticket/1292

-- 
Endi S. Dewata
-------------- next part --------------
From 8caf5b148f57610506cfc2937f1bbcc6090619af Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata at redhat.com>
Date: Fri, 10 Apr 2015 04:44:30 -0400
Subject: [PATCH] Customized TPS UI menu based on user roles.

The TPS UI has been modified to customize the navigation menu
based on the roles of the user currently logged in. TPS agents
do not have access to user, group, config, authenticator,
connector, profile mapping, audit, and self test services, so
the corresponding menu items will not be visible. TPS admins
have access to all menu items.

https://fedorahosted.org/pki/ticket/1292
---
 base/tps/shared/webapps/tps/js/tps.js     |  2 ++
 base/tps/shared/webapps/tps/ui/index.html | 37 ++++++++++++++++++++++---------
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/base/tps/shared/webapps/tps/js/tps.js b/base/tps/shared/webapps/tps/js/tps.js
index 4765337592ff2acebda0fe3f3d54793c56d4c47c..263ebce2614d3db709281460dad9b8e6ac47a164 100644
--- a/base/tps/shared/webapps/tps/js/tps.js
+++ b/base/tps/shared/webapps/tps/js/tps.js
@@ -19,6 +19,8 @@
  * @author Endi S. Dewata
  */
 
+var tps = {}
+
 var PropertiesTableItem = TableItem.extend({
     initialize: function(options) {
         var self = this;
diff --git a/base/tps/shared/webapps/tps/ui/index.html b/base/tps/shared/webapps/tps/ui/index.html
index 74adeadd14a7355c67dd92bba9c03958221d9023..87e424eec2da20ef795f70a5843e636bfad9fd4a 100644
--- a/base/tps/shared/webapps/tps/ui/index.html
+++ b/base/tps/shared/webapps/tps/ui/index.html
@@ -47,10 +47,26 @@ $(function() {
     var account = new Account();
     account.login({
         success: function(data, textStatus, jqXHR) {
+            tps.user = data;
+            var roles = tps.user.Roles.Role;
+
             var user = $("#user");
             user.text(data.FullName);
+
+            var accounts_menu = $("#navigation [name=accounts]");
+            var system_menu = $("#navigation [name=system]");
+
+            if (_.contains(roles, "Administrators")) {
+                accounts_menu.show();
+                $("li", system_menu).show();
+
+            } else if (_.contains(roles, "TPS Agents")) {
+                accounts_menu.hide();
+                $("li", system_menu).hide();
+                $("[name=profiles]", system_menu).show();
+            }
         },
-        error: function() {
+        error: function(jqXHR, textStatus, errorThrown) {
             window.location.href = "/tps";
         }
     });
@@ -330,6 +346,7 @@ $(function() {
         // destroy server session
         account.logout({
             success: function() {
+                tps.user = null;
                 // clear browser cache
                 PKI.logout({
                     success: function() {
@@ -382,7 +399,7 @@ $(function() {
     <li><a href="#tokens">Tokens</a></li>
     <li><a href="#certs">Certificates</a></li>
     <li><a href="#activities">Activities</a></li>
-    <li class="dropdown context">
+    <li name="accounts" class="dropdown context" style="display: none;">
       <a href="#" class="dropdown-toggle" data-toggle="dropdown">
         Accounts
         <b class="caret"></b>
@@ -392,19 +409,19 @@ $(function() {
         <li><a href="#groups">Groups</a></li>
       </ul>
     </li>
-    <li class="dropdown context">
+    <li name="system" class="dropdown context">
       <a href="#" class="dropdown-toggle" data-toggle="dropdown">
         System
         <b class="caret"></b>
       </a>
       <ul class="dropdown-menu">
-        <li><a href="#config">General Configuration</a></li>
-        <li><a href="#authenticators">Authentication Sources</a></li>
-        <li><a href="#connectors">Subsystem Connections</a></li>
-        <li><a href="#profiles">Profiles</a></li>
-        <li><a href="#profile-mappings">Profile Mappings</a></li>
-        <li><a href="#audit">Audit Logging</a></li>
-        <li><a href="#selftests">Self Tests</a></li>
+        <li name="config" style="display: none;"><a href="#config">General Configuration</a></li>
+        <li name="authenticators" style="display: none;"><a href="#authenticators">Authentication Sources</a></li>
+        <li name="connectors" style="display: none;"><a href="#connectors">Subsystem Connections</a></li>
+        <li name="profiles" style="display: none;"><a href="#profiles">Profiles</a></li>
+        <li name="profile-mappings" style="display: none;"><a href="#profile-mappings">Profile Mappings</a></li>
+        <li name="audit" style="display: none;"><a href="#audit">Audit Logging</a></li>
+        <li name="selftests" style="display: none;"><a href="#selftests">Self Tests</a></li>
       </ul>
     </li>
     </ul>
-- 
1.9.3



More information about the Pki-devel mailing list