Преглед на файлове

[security] Support privileges with grant option

Romain Rigaux преди 11 години
родител
ревизия
334ceb0
променени са 3 файла, в които са добавени 16 реда и са изтрити 5 реда
  1. 4 2
      apps/security/src/security/api/hive.py
  2. 11 3
      apps/security/src/security/templates/hive.mako
  3. 1 0
      apps/security/static/js/hive.ko.js

+ 4 - 2
apps/security/src/security/api/hive.py

@@ -62,7 +62,8 @@ def _to_sentry_privilege(privilege):
       'tableName': privilege['tableName'],
       'URI': privilege['URI'],
       'action': privilege['action'],
-      'createTime': privilege['timestamp']
+      'createTime': privilege['timestamp'],
+      'grantOption': 1 if privilege['grantOption'] else 0,
   }  
 
 
@@ -83,7 +84,8 @@ def _hive_add_privileges(user, role, privileges):
             'scope': privilege.get('privilegeScope'),
             'table': privilege.get('tableName'),
             'URI': privilege.get('URI'),            
-            'server': privilege.get('serverName')
+            'server': privilege.get('serverName'),
+            'grantOption': privilege.get('grantOption') == 1
         })
 
     return _privileges

+ 11 - 3
apps/security/src/security/templates/hive.mako

@@ -63,7 +63,11 @@ ${ layout.menubar(section='hive') }
     <input type="text" data-bind="filechooser: $data.URI, enable: privilegeType() == 'uri'" placeholder="URI">
 
     <select data-bind="options: $root.availableActions, select2: { update: $data.action, type: 'action'}" style="width: 100px"></select>
-
+    
+    <div class="inline-block" style="vertical-align: middle">
+      <input type="checkbox" data-bind="checked: grantOption"> ${ _('With grant') }
+    </div>
+    
     <span class="showAdvancedSpace">&nbsp;&nbsp;</span><a class="pointer showAdvanced" data-bind="click: function(){ showAdvanced(true); }, visible: ! showAdvanced()"><i class="fa fa-cog"></i> ${ _('Show advanced') }</a>
 
     <div class="acl-block-section" data-bind="visible: showAdvanced">
@@ -95,11 +99,15 @@ ${ layout.menubar(section='hive') }
       <i class="fa fa-long-arrow-right"></i> action=<span data-bind="text: action"></span>
     <!-- /ko -->
     
-    <!-- ko if: URI() -->    
+    <!-- ko if: grantOption() -->
+      <i class="fa fa-link" title="${ _('With grant option') }"></i>
+    <!-- /ko -->
+    
+    <!-- ko if: URI() -->
       <span data-bind="text: URI"></span>
     <!-- /ko -->
     <br/>
-    <span data-bind="text: grantor"></span>    
+    <span data-bind="text: grantor"></span>
   <!-- /ko -->
 </div>
 </script>

+ 1 - 0
apps/security/static/js/hive.ko.js

@@ -65,6 +65,7 @@ var Privilege = function (vm, privilege) {
   });
   self.timestamp = ko.observable(typeof privilege.timestamp != "undefined" && privilege.timestamp != null ? privilege.timestamp : 0);
   self.grantor = ko.observable(typeof privilege.grantor != "undefined" && privilege.grantor != null ? privilege.grantor : "");
+  self.grantOption = ko.observable(typeof privilege.grantOption != "undefined" && privilege.grantOption != null ? privilege.grantOption : false);
 
   // UI
   self.privilegeType = ko.observable("db");