Browse Source

HUE-7825 [sentry] Integrate new 'admin' Sentry Solr permissions

Romain Rigaux 8 years ago
parent
commit
8931b28d86

+ 3 - 1
apps/security/src/security/api/sentry.py

@@ -84,13 +84,15 @@ def _fetch_collections(request):
   api = SolrApi(SOLR_URL.get(), request.user)
   api = SolrApi(SOLR_URL.get(), request.user)
 
 
   if not item:
   if not item:
-    return {"databases": ["collections", "configs"]}
+    return {"databases": ["collections", "configs", "admin"]}
   elif item and name:
   elif item and name:
     return {"authorizable_link": "/indexer/#edit/%s" % name, "extended_columns": [], "columns": [], "partition_keys": []}
     return {"authorizable_link": "/indexer/#edit/%s" % name, "extended_columns": [], "columns": [], "partition_keys": []}
   elif item == 'collections':
   elif item == 'collections':
     return {"tables_meta": [{"comment": None, "type": "Table", "name": col} for col in api.collections2()]}
     return {"tables_meta": [{"comment": None, "type": "Table", "name": col} for col in api.collections2()]}
   elif item == 'configs':
   elif item == 'configs':
     return {"tables_meta": [{"comment": None, "type": "Table", "name": conf} for conf in api.configs()]}
     return {"tables_meta": [{"comment": None, "type": "Table", "name": conf} for conf in api.configs()]}
+  elif item == 'admin':
+    return {"tables_meta": [{"comment": None, "type": "Table", "name": 'collections'}, {"comment": None, "type": "Table", "name": "cores"}]}
   else:
   else:
     raise PopupException(_('Authorizable %s could not be retrieved') % path)
     raise PopupException(_('Authorizable %s could not be retrieved') % path)
 
 

+ 6 - 1
apps/security/src/security/static/security/js/sentry.ko.js

@@ -115,6 +115,9 @@ var SentryViewModel = (function () {
           else if (_parts[0] == 'configs') {
           else if (_parts[0] == 'configs') {
             self.authorizables.push(new Authorizable(vm, self, {type: 'CONFIG', name: _parts[1]}))
             self.authorizables.push(new Authorizable(vm, self, {type: 'CONFIG', name: _parts[1]}))
           }
           }
+          else if (_parts[0] == 'admin') {
+            self.authorizables.push(new Authorizable(vm, self, {type: 'ADMIN', name: _parts[1]}))
+          }
         } else {
         } else {
           self.authorizables.push(new Authorizable(vm, self, {type: 'DATABASE', name: _parts[0]}))
           self.authorizables.push(new Authorizable(vm, self, {type: 'DATABASE', name: _parts[0]}))
           if (_parts.length > 1) {
           if (_parts.length > 1) {
@@ -1139,7 +1142,9 @@ var SentryViewModel = (function () {
 
 
       if (self.component() == 'solr') {
       if (self.component() == 'solr') {
         if (paths.length > 1) {
         if (paths.length > 1) {
-          if (paths[0] == 'configs') {
+          if (paths[0] == 'admin') {
+            authorizables.push({'type': 'ADMIN', 'name': paths[1]});
+          } else if (paths[0] == 'configs') {
             authorizables.push({'type': 'CONFIG', 'name': paths[1]});
             authorizables.push({'type': 'CONFIG', 'name': paths[1]});
           } else {
           } else {
             authorizables.push({'type': 'COLLECTION', 'name': paths[1]});
             authorizables.push({'type': 'COLLECTION', 'name': paths[1]});

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

@@ -80,7 +80,7 @@ ${ layout.menubar(section=component, is_embeddable=is_embeddable) }
 
 
     <!-- ko if: $root.component() == 'solr' -->
     <!-- ko if: $root.component() == 'solr' -->
       <input type="text" class="input-xxlarge" data-bind="solrchooser: $data.path" placeholder="collection or config name <CTRL+SPACE>">
       <input type="text" class="input-xxlarge" data-bind="solrchooser: $data.path" placeholder="collection or config name <CTRL+SPACE>">
-      <select data-bind="options: privilegeType() == 'CONFIG' ? $root.availableSolrConfigActions : $root.availableActions, value: $data.action, enable: (privilegeType() == 'COLLECTION')" style="width: 100px; margin-bottom: 0"></select>
+      <select data-bind="options: privilegeType() == 'CONFIG' ? $root.availableSolrConfigActions : $root.availableActions, value: $data.action, enable: privilegeType() != 'CONFIG'" style="width: 100px; margin-bottom: 0"></select>
     <!-- /ko -->
     <!-- /ko -->
 
 
     <div class="new-line-if-small">
     <div class="new-line-if-small">

+ 3 - 1
desktop/core/src/desktop/static/desktop/js/jquery.hiveautocomplete.js

@@ -313,6 +313,8 @@
             if (self.options.serverType == "SOLR") {
             if (self.options.serverType == "SOLR") {
               if (item.isCollection && !firstSolrCollection) {
               if (item.isCollection && !firstSolrCollection) {
                 _currentFiles.push('<li class="hiveAutocompleteItem" data-value="collections.*" title="collections.*"><i class="fa fa-search-plus"></i> collections.*</li>');
                 _currentFiles.push('<li class="hiveAutocompleteItem" data-value="collections.*" title="collections.*"><i class="fa fa-search-plus"></i> collections.*</li>');
+                _currentFiles.push('<li class="hiveAutocompleteItem" data-value="admin.collections" title="admin.collections"><i class="fa fa-database"></i> admin.collections</li>');
+                _currentFiles.push('<li class="hiveAutocompleteItem" data-value="admin.cores" title="admin.collections"><i class="fa fa-database"></i> admin.cores</li>');
                 firstSolrCollection = true;
                 firstSolrCollection = true;
               }
               }
               if (item.isConfig) {
               if (item.isConfig) {
@@ -339,7 +341,7 @@
             var item = $(this).text().trim();
             var item = $(this).text().trim();
             var path = autocompleteUrl.substring(BASE_PATH.length);
             var path = autocompleteUrl.substring(BASE_PATH.length);
 
 
-            if ($(this).html().indexOf("search") > -1 || $(this).html().indexOf("cog") > -1) {
+            if ($(this).html().indexOf("search") > -1 || $(this).html().indexOf("cog") > -1 || $(this).html().indexOf("database") > -1) {
               if ($(this).html().indexOf("search") > -1 && $(this).html().indexOf("search-plus") == -1) {
               if ($(this).html().indexOf("search") > -1 && $(this).html().indexOf("search-plus") == -1) {
                 $el.val("collections." + item);
                 $el.val("collections." + item);
               }
               }

+ 1 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3179,6 +3179,7 @@
         showOnFocus: true,
         showOnFocus: true,
         home: "/",
         home: "/",
         serverType: "SOLR",
         serverType: "SOLR",
+        skipTables: true, // No notion of DB actually
         onPathChange: function (path) {
         onPathChange: function (path) {
           setPathFromAutocomplete(path);
           setPathFromAutocomplete(path);
         },
         },