Browse Source

HUE-3720 [security] Allow to browse Solr observable hierarchies

Romain Rigaux 9 năm trước cách đây
mục cha
commit
497df2c

+ 5 - 1
desktop/libs/libsentry/src/libsentry/api2.py

@@ -174,7 +174,7 @@ class SentryApi(object):
       _roles = {}
       for role, privileges in roles.privilegeMap.iteritems():
         _roles[role] = [self._massage_privilege(privilege) for privilege in privileges]
-      _privileges.append((self._massage_authorizable(authorizable), _roles))
+      _privileges.append((self._massage_string_authorizable(authorizable), _roles))
 
     return _privileges
 
@@ -213,6 +213,10 @@ class SentryApi(object):
     return [{'type': auth.type, 'name': auth.name} for auth in authorizables]
 
 
+  def _massage_string_authorizable(self, authorizables):
+    return [{'type': auth.split('=')[0], 'name': auth.split('=')[1]} for auth in authorizables.split('->')]
+
+
 class SentryException(Exception):
   def __init__(self, e):
     super(SentryException, self).__init__(e)

+ 2 - 6
desktop/libs/libsentry/src/libsentry/client2.py

@@ -176,14 +176,10 @@ class SentryClient(object):
 
 
   def list_sentry_privileges_by_authorizable(self, serviceName, authorizableSet, groups=None, roleSet=None):
-    authorizableSet = ['%s->%s' % (_auth['type'], _auth['name']) for _authSet in authorizableSet for _auth in _authSet['authorizables']]
+    authorizableSet = ['%s=%s' % (_auth['type'], _auth['name']) for _authSet in authorizableSet for _auth in _authSet['authorizables']]
 
     if roleSet is not None:
       roleSet = TSentryActiveRoleSet(**roleSet)
 
     request = TListSentryPrivilegesByAuthRequest(requestorUserName=self.username, component=self.component, serviceName=serviceName, authorizablesSet=set(authorizableSet), groups=groups, roleSet=roleSet)
-    #return self.client.list_sentry_privileges_by_authorizable(request)
-    return type('Response', (object,), {
-        'status': type('Status', (object,), {'value': 0}),
-        'privilegesMapByAuth': {}
-    })
+    return self.client.list_sentry_privileges_by_authorizable(request)