Browse Source

[security] Delegate list all privileges filtering to authorizableHierarchy

Romain Rigaux 11 năm trước cách đây
mục cha
commit
e5d26c7dcf

+ 3 - 6
apps/security/src/security/api/hive.py

@@ -210,10 +210,9 @@ def list_sentry_privileges_by_authorizable(request):
     roles = get_api(request.user).list_sentry_roles_by_group(groupName=groupName)
 
     for role in roles:
-      for privilege in get_api(request.user).list_sentry_privileges_by_role(role['name']): # authorizableHierarchy not working here?
-        if privilege['database'] == authorizableHierarchy['db'] and ('table' not in authorizableHierarchy or privilege['table'] == authorizableHierarchy['table']):
-          privilege['roleName'] = role['name']
-          privileges.append(privilege)
+      for privilege in get_api(request.user).list_sentry_privileges_by_role(role['name'], authorizableHierarchy=authorizableHierarchy):
+        privilege['roleName'] = role['name']
+        privileges.append(privilege)
 
     result['privileges'] = privileges
 
@@ -230,7 +229,6 @@ def bulk_delete_privileges(request):
 
   try:
     checkedPaths = json.loads(request.POST['checkedPaths'])
-    recursive = json.loads(request.POST['recursive'])
     authorizableHierarchy = json.loads(request.POST['authorizableHierarchy'])
 
     for path in [path['path'] for path in checkedPaths]:
@@ -257,7 +255,6 @@ def bulk_add_privileges(request):
   try:
     privileges = json.loads(request.POST['privileges'])
     checkedPaths = json.loads(request.POST['checkedPaths'])
-    recursive = json.loads(request.POST['recursive'])
     authorizableHierarchy = json.loads(request.POST['authorizableHierarchy'])
 
     privileges = [privilege for privilege in privileges if privilege['status'] == '']

+ 1 - 1
apps/security/src/security/templates/hive.mako

@@ -131,7 +131,7 @@ ${ layout.menubar(section='hive') }
               <div class="path-container">
                 <div class="input-append span12">
                   <input id="path" class="path" type="text" autocomplete="off" />
-                  <a data-bind="attr: { href: '/metastore/' + $root.assist.path() }" target="_blank" title="${ _('Open in Metastore Browser') }" class="btn btn-inverse">
+                  <a data-bind="attr: { href: '/metastore/table/' + $root.assist.path().replace('.', '/') }" target="_blank" title="${ _('Open in Metastore Browser') }" class="btn btn-inverse">
                     <i class="fa fa-external-link"></i>
                   </a>
                 </div>