Эх сурвалжийг харах

[security] Make both Sentry API v1 and v2 pluggable

Romain Rigaux 10 жил өмнө
parent
commit
88ce3af

+ 15 - 3
apps/security/src/security/conf.py

@@ -20,8 +20,20 @@ from django.utils.translation import ugettext_lazy as _
 from desktop.lib.conf import Config, coerce_bool
 
 
-LATEST = Config(
-  key="latest",
-  help=_("Use Sentry generic API V2 for Hive and Solr."),
+HIVE_V1 = Config(
+  key="hive_v1",
+  help=_("Use Sentry API V1 for Hive."),
+  default=True,
+  type=coerce_bool)
+
+HIVE_V2 = Config(
+  key="hive_v2",
+  help=_("Use Sentry generic API V2 for Hive."),
+  default=False,
+  type=coerce_bool)
+
+SOLR_V2 = Config(
+  key="solr_v2",
+  help=_("Use Sentry generic API V2 for Solr."),
   default=False,
   type=coerce_bool)

+ 6 - 2
apps/security/src/security/templates/layout.mako

@@ -16,7 +16,7 @@
 
 <%!
 from django.utils.translation import ugettext as _
-from security.conf import LATEST
+from security.conf import HIVE_V1, HIVE_V2, SOLR_V2
 
 def is_selected(section, matcher):
   if section == matcher:
@@ -63,9 +63,13 @@ def is_selected(section, matcher):
                   ${ _('Hadoop Security') }
                 </a>
               </li>
+              % if HIVE_V1.get():
               <li class="${is_selected(section, 'hive')}"><a href="${ url('security:hive') }">${_('Sentry Tables')}</a></li>
-              % if LATEST.get():
+              % endif
+              % if HIVE_V2.get():
               <li class="${is_selected(section, 'hive2')}"><a href="${ url('security:hive2') }">${_('Sentry Tables v2')}</a></li>
+              % endif
+              % if SOLR_V2.get():
               <li class="${is_selected(section, 'solr')}"><a href="${ url('security:hive') }">${_('Solr Collections')}</a></li>
               % endif
               <li class="${is_selected(section, 'hdfs')}"><a href="${ url('security:hdfs') }">${_('File ACLs')}</a></li>

+ 8 - 2
desktop/conf.dist/hue.ini

@@ -1041,8 +1041,14 @@
 
 [security]
 
-  # Use Sentry generic API V2 for Hive and Solr.
-  ## latest=false
+  # Use Sentry API V1 for Hive.
+  ## hive_v1=true
+
+  # Use Sentry API V2 for Hive.
+  ## hive_v2=false
+
+  # Use Sentry API V2 for Solr.
+  ## solr_v2=false
 
 
 ###########################################################################

+ 8 - 2
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1043,8 +1043,14 @@
 
 [security]
 
-  # Use Sentry generic API V2 for Hive and Solr.
-  ## latest=false
+  # Use Sentry API V1 for Hive.
+  ## hive_v1=true
+
+  # Use Sentry API V2 for Hive.
+  ## hive_v2=false
+
+  # Use Sentry API V2 for Solr.
+  ## solr_v2=false
 
 
 ###########################################################################

+ 6 - 2
desktop/core/src/desktop/templates/common_header.mako

@@ -566,13 +566,17 @@ from django.utils.translation import ugettext as _
          % endif
        % endif
        % if 'security' in apps:
-         <% from security.conf import LATEST %>
+         <% from security.conf import HIVE_V1, HIVE_V2, SOLR_V2 %>
          <li class="dropdown">
            <a title="${_('Hadoop Security')}" rel="navigator-tooltip" href="#" data-toggle="dropdown" class="dropdown-toggle">Security <b class="caret"></b></a>
            <ul role="menu" class="dropdown-menu">
+             % if HIVE_V1.get():
              <li><a href="${ url('security:hive') }">&nbsp;<img src="/static/metastore/art/icon_metastore_48.png" class="app-icon"></img>&nbsp;&nbsp;${_('Sentry Tables')}</a></li>
-             % if LATEST.get():
+             % endif
+             % if HIVE_V2.get():
              <li><a href="${ url('security:hive2') }">&nbsp;<img src="/static/metastore/art/icon_metastore_48.png" class="app-icon"></img>&nbsp;&nbsp;${_('Sentry Tables v2')}</a></li>
+             % endif
+             % if SOLR_V2.get():
              <li><a href="${ url('security:solr') }">&nbsp;<i class="fa fa-database"></i>&nbsp;&nbsp;${_('Solr Collections')}</a></li>
              % endif
              <li><a href="${ url('security:hdfs') }">&nbsp;<i class="fa fa-file"></i>&nbsp;&nbsp;${_('File ACLs')}</a></li>

+ 3 - 2
desktop/libs/libsentry/src/libsentry/api.py

@@ -24,10 +24,11 @@ import time
 from django.utils.translation import ugettext as _
 
 from desktop.lib.exceptions_renderable import PopupException
-from libsentry.client2 import SentryClient
+from libzookeeper.models import ZookeeperClient
+
+from libsentry.client import SentryClient
 from libsentry.conf import HOSTNAME, PORT
 from libsentry.sentry_site import get_sentry_server_ha_enabled, get_sentry_server_ha_zookeeper_quorum, get_sentry_server_ha_zookeeper_namespace
-from libzookeeper.models import ZookeeperClient
 
 
 LOG = logging.getLogger(__name__)