incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [13/13] git commit: Applied security patch from aavenosa
Date Wed, 09 Jul 2014 19:40:46 GMT
Applied security patch from aavenosa


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/a0390e35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/a0390e35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/a0390e35

Branch: refs/heads/apache-blur-0.2
Commit: a0390e35c13587077bd63bf789b970de0960eb08
Parents: a8c4cd0
Author: Chris Rohr <rohr.chris@gmail.com>
Authored: Wed Jul 9 15:40:23 2014 -0400
Committer: Chris Rohr <rohr.chris@gmail.com>
Committed: Wed Jul 9 15:40:23 2014 -0400

----------------------------------------------------------------------
 .../org/apache/blur/console/JettyServer.java    |   22 +-
 .../blur/console/servlets/AuthServlet.java      |   10 +-
 .../org/apache/blur/console/util/Config.java    |   15 +-
 blur-console/src/main/webapp/index.html         |    5 +-
 .../src/main/webapp/js/blurconsole.data.js      |   11 +-
 .../src/main/webapp/js/blurconsole.fake.js      |    8 +-
 .../src/main/webapp/js/blurconsole.model.js     |   23 +-
 .../src/main/webapp/js/blurconsole.search.js    |   57 +-
 ...console.999552265d9d28485193f204f1f343fa.css | 6476 ------------------
 ...console.bfe9062c877a3904cde5eaa94c865433.css | 6476 ++++++++++++++++++
 .../src/main/webapp/public/css/blurconsole.css  |    2 +-
 ...ole.css.7810da8b2de20654a46bcb77fb0a906b.map |    1 -
 ...ole.css.85b4970e6cc85ff19b38ea3992343cc9.map |    1 +
 .../main/webapp/public/css/blurconsole.css.map  |    2 +-
 blur-console/src/main/webapp/public/index.html  |    9 +-
 ...rconsole.168edfdcdf6a34e319b24b4b5e8fde60.js |   27 -
 ...rconsole.2386c8f423ff1369e4d7b407401ca2b4.js |   27 +
 .../src/main/webapp/public/js/blurconsole.js    |    6 +-
 ...sole.js.3d61abd256a11df56d1a1f64c87da231.map |    1 -
 ...sole.js.d5898caf0c8a8e22f30591d3c774457f.map |    1 +
 .../main/webapp/public/js/blurconsole.js.map    |    2 +-
 21 files changed, 6627 insertions(+), 6555 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/a0390e35/blur-console/src/main/java/org/apache/blur/console/JettyServer.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/JettyServer.java b/blur-console/src/main/java/org/apache/blur/console/JettyServer.java
index b05c3eb..59b7ae0 100644
--- a/blur-console/src/main/java/org/apache/blur/console/JettyServer.java
+++ b/blur-console/src/main/java/org/apache/blur/console/JettyServer.java
@@ -20,11 +20,14 @@ package org.apache.blur.console;
 import org.apache.blur.console.servlets.*;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jasper.tagplugins.jstl.core.Url;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.servlet.Context;
 import org.mortbay.jetty.servlet.ServletHolder;
 import org.mortbay.jetty.webapp.WebAppContext;
 
+import java.io.File;
+import java.net.MalformedURLException;
 import java.net.URL;
 
 public class JettyServer {
@@ -32,8 +35,8 @@ public class JettyServer {
   private Server server;
   private boolean devMode;
 
-  private static final String DEV_WEBAPPDIR = "../classes/";
-  private static final String PROD_WEBAPPDIR = "webapp/";
+  private static final String DEV_WEBAPPDIR = "src/main/webapp/public/";
+  private static final String PROD_WEBAPPDIR = "webapp/public/";
   private static final String CONTEXTPATH = "/console";
 
   private final Log log = LogFactory.getLog(JettyServer.class);
@@ -43,7 +46,7 @@ public class JettyServer {
     this.devMode = devMode;
   }
 
-  public JettyServer start() {
+  public JettyServer start() throws MalformedURLException {
     createServer();
     return this;
   }
@@ -56,16 +59,16 @@ public class JettyServer {
     }
   }
 
-  private void createServer() {
+  private void createServer() throws MalformedURLException {
     server = new Server(port);
 
     // for localhost:port/console/index.html and whatever else is in the webapp directory
     URL warUrl = null;
-    if (devMode) {
-      warUrl = this.getClass().getClassLoader().getResource(DEV_WEBAPPDIR);
-    } else {
-      warUrl = this.getClass().getClassLoader().getResource(PROD_WEBAPPDIR);
-    }
+      if (devMode) {
+          warUrl = new URL("file://" + new File(DEV_WEBAPPDIR).getAbsolutePath());
+      } else {
+          warUrl = this.getClass().getClassLoader().getResource(PROD_WEBAPPDIR);
+      }
     String warUrlString = warUrl.toExternalForm();
     server.setHandler(new WebAppContext(warUrlString, CONTEXTPATH));
 
@@ -77,6 +80,7 @@ public class JettyServer {
     context.addServlet(new ServletHolder(new QueriesServlet()), "/queries/*");
     context.addServlet(new ServletHolder(new SearchServlet()), "/search/*");
 
+    System.out.println("started server on http://localhost:" + port + CONTEXTPATH);
     try {
       server.start();
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/a0390e35/blur-console/src/main/java/org/apache/blur/console/servlets/AuthServlet.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/servlets/AuthServlet.java
b/blur-console/src/main/java/org/apache/blur/console/servlets/AuthServlet.java
index 078f27a..5646b56 100644
--- a/blur-console/src/main/java/org/apache/blur/console/servlets/AuthServlet.java
+++ b/blur-console/src/main/java/org/apache/blur/console/servlets/AuthServlet.java
@@ -40,9 +40,10 @@ public class AuthServlet extends BaseConsoleServlet {
   @Override
   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
     String path = req.getPathInfo();
-
     if (path == null) {
       checkCurrentAuth(req, resp);
+    } else if ("/securityUsers".equalsIgnoreCase(path)) {
+      getSecurityUsers(req, resp);
     } else {
       sendNotFound(resp, req.getRequestURI());
     }
@@ -51,7 +52,6 @@ public class AuthServlet extends BaseConsoleServlet {
   @Override
   protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
     String path = req.getPathInfo();
-
     if ("login".equalsIgnoreCase(path)) {
       loginUser(req, resp);
     } else {
@@ -59,6 +59,12 @@ public class AuthServlet extends BaseConsoleServlet {
     }
   }
 
+  private void getSecurityUsers(HttpServletRequest request, HttpServletResponse response)
throws IOException {
+    Map<String, Object> responseData = new HashMap<String, Object>();
+    responseData.put("securityUserNames", Config.getSecurityUserNames());
+    HttpUtil.sendResponse(response, new ObjectMapper().writeValueAsString(responseData),
HttpUtil.JSON);
+  }
+
   private void checkCurrentAuth(HttpServletRequest request, HttpServletResponse response)
throws IOException {
     IProvider provider = Config.getProvider();
     Map<String, Object> responseData = new HashMap<String, Object>();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/a0390e35/blur-console/src/main/java/org/apache/blur/console/util/Config.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/util/Config.java b/blur-console/src/main/java/org/apache/blur/console/util/Config.java
index 3afe048..f9bcf3f 100644
--- a/blur-console/src/main/java/org/apache/blur/console/util/Config.java
+++ b/blur-console/src/main/java/org/apache/blur/console/util/Config.java
@@ -17,6 +17,7 @@ package org.apache.blur.console.util;
  * limitations under the License.
  */
 
+
 import org.apache.blur.BlurConfiguration;
 import org.apache.blur.console.providers.AllAllowedProvider;
 import org.apache.blur.console.providers.IProvider;
@@ -37,6 +38,7 @@ import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -92,9 +94,7 @@ public class Config {
       JsonFactory factory = new JsonFactory();
       ObjectMapper mapper = new ObjectMapper(factory);
       File from = new File(securityFile);
-      TypeReference<Map<String, Map<String, String>>> typeRef
-          = new TypeReference<Map<String, Map<String, String>>>() {
-      };
+      TypeReference<Map<String, Map<String, String>>> typeRef = new TypeReference<Map<String,
Map<String, String>>>(){};
 
       try {
         globalUserProperties = mapper.readValue(from, typeRef);
@@ -188,4 +188,13 @@ public class Config {
   public static IProvider getProvider() {
     return provider;
   }
+
+  public static Collection<String> getSecurityUserNames() {
+    if(globalUserProperties != null) {
+      return globalUserProperties.keySet();
+    } else {
+      return new ArrayList<String>();
+    }
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/a0390e35/blur-console/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/index.html b/blur-console/src/main/webapp/index.html
index c405256..a4aaa2e 100644
--- a/blur-console/src/main/webapp/index.html
+++ b/blur-console/src/main/webapp/index.html
@@ -66,10 +66,7 @@ under the License.
     <div id="blurconsole"></div>
     <script src="js/blurconsole.js"></script>
     <script type="text/javascript">
-            $(function () { blurconsole.initModule( $('#blurconsole') ); });
-
-
-
+      $(function () { blurconsole.initModule( $('#blurconsole') ); });
     </script>
   </body>
 </html>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/a0390e35/blur-console/src/main/webapp/js/blurconsole.data.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.data.js b/blur-console/src/main/webapp/js/blurconsole.data.js
index 056a8c1..3473b99 100644
--- a/blur-console/src/main/webapp/js/blurconsole.data.js
+++ b/blur-console/src/main/webapp/js/blurconsole.data.js
@@ -115,6 +115,14 @@ blurconsole.data = (function() {
     });
   }
 
+  function getSecurityUserNames(callback) {
+    $.getJSON('/service/auth/securityUsers', function(data) {
+      callback(data.securityUserNames);
+    }).fail(function(xhr) {
+      _logError(xhr.responseText, xhr.status, 'securityUsers');
+    });
+  }
+
   return {
     getTableList : getTableList,
     getNodeList : getNodeList,
@@ -126,6 +134,7 @@ blurconsole.data = (function() {
     deleteTable : deleteTable,
     getSchema : getSchema,
     findTerms : findTerms,
-    sendSearch : sendSearch
+    sendSearch : sendSearch,
+    getSecurityUserNames : getSecurityUserNames
   };
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/a0390e35/blur-console/src/main/webapp/js/blurconsole.fake.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.fake.js b/blur-console/src/main/webapp/js/blurconsole.fake.js
index 6400345..c6bb79c 100644
--- a/blur-console/src/main/webapp/js/blurconsole.fake.js
+++ b/blur-console/src/main/webapp/js/blurconsole.fake.js
@@ -259,6 +259,11 @@ blurconsole.fake = (function() {
       _sendCallback(callback, { families: fams, results: results, total: total });
     }
   }
+
+  function getSecurityUserNames(callback) {
+    _sendCallback(callback, ['superuser','limiteduser']);
+  }
+
   function initModule() {
     $('nav.navbar .pull-right').append('<button type="button" id="fake_freeze" class="btn
btn-default btn-sm">Freeze</button>');
     $('#fake_freeze').click(_toggleFreeze);
@@ -276,6 +281,7 @@ blurconsole.fake = (function() {
     deleteTable : deleteTable,
     getSchema : getSchema,
     findTerms : findTerms,
-    sendSearch : sendSearch
+    sendSearch : sendSearch,
+    getSecurityUserNames : getSecurityUserNames
   };
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/a0390e35/blur-console/src/main/webapp/js/blurconsole.model.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.model.js b/blur-console/src/main/webapp/js/blurconsole.model.js
index 2c2c52e..4f5511e 100644
--- a/blur-console/src/main/webapp/js/blurconsole.model.js
+++ b/blur-console/src/main/webapp/js/blurconsole.model.js
@@ -33,7 +33,8 @@ blurconsole.model = (function() {
       queryPerformance : [],
       queries : {},
       errors: [],
-      schema: {}
+      schema: {},
+      securityUserNames: null
     };
 
   //----------------------- Models ----------------------------------
@@ -487,6 +488,23 @@ blurconsole.model = (function() {
     };
   }());
 
+  var security = (function() {
+    function userNames(callback) {
+      if(stateMap.securityUserNames) {
+        callback(stateMap.securityUserNames);
+      } else {
+        configMap.poller.getSecurityUserNames(function(data) {
+          stateMap.securityUserNames = data;
+          callback(data);
+        });
+      }
+    }
+
+    return {
+      userNames: userNames
+    };
+  }());
+
   //----------------------- Private Methods -------------------------
   function _nodePoller() {
     configMap.poller.getNodeList(_updateNodes);
@@ -568,6 +586,7 @@ blurconsole.model = (function() {
     nodes : nodes,
     queries : queries,
     search : search,
-    logs: logs
+    logs: logs,
+    security: security
   };
 }());
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/a0390e35/blur-console/src/main/webapp/js/blurconsole.search.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.search.js b/blur-console/src/main/webapp/js/blurconsole.search.js
index 6263c18..38d8a32 100644
--- a/blur-console/src/main/webapp/js/blurconsole.search.js
+++ b/blur-console/src/main/webapp/js/blurconsole.search.js
@@ -19,8 +19,8 @@ under the License.
 /*global blurconsole:false, confirm:false */
 blurconsole.search = (function () {
   'use strict';
-    
-    //----------------------------- Configuration and State --------------------------------
+
+  //----------------------------- Configuration and State --------------------------------
   var configMap = {
     view : 'views/search.tpl.html',
     superQueryMap: {
@@ -29,12 +29,14 @@ blurconsole.search = (function () {
       'recordrecord' : 'Search Record / Retrieve Record'
     },
     optionsHtml:
+      '<div class="form-group">' +
       '<label for="superQuery">Search & Retrieve</label>' +
-      '<select id="superQuery">' +
-        '<option value="rowrow">Search Row / Retrieve Row</option>' +
-        '<option value="recordrow">Search Record / Retrieve Row</option>' +
-        '<option value="recordrecord">Search Record / Retrieve Record</option>'
+
-      '</select>'
+      '<select id="superQuery" class="form-control"></select>' +
+      '</div>' +
+      '<div class="form-group">' +
+      '<label for="user">User</label>' +
+      '<select id="user" class="form-control"></select>' +
+      '</div>'
   },
   stateMap = {
     $container : null,
@@ -44,11 +46,12 @@ blurconsole.search = (function () {
     $start : 0,
     $fetch : 10,
     $filter : null,
-    $rowRecordOption : 'rowrow'
+    $rowRecordOption : 'rowrow',
+    $userOption : null
   },
   jqueryMap = {};
-    
-    //----------------- Private Methods ----------------------------------
+
+  //----------------- Private Methods ----------------------------------
   function _setJqueryMap() {
     var $container = stateMap.$container;
     jqueryMap = {
@@ -220,7 +223,7 @@ blurconsole.search = (function () {
     return cols;
   }
 
-    //------------------------------ Event Handlers and DOM Methods ---------------------
+  //------------------------------ Event Handlers and DOM Methods ---------------------
   function _updateOptionDisplay() {
     var displayText = '';
     displayText += configMap.superQueryMap[stateMap.$rowRecordOption];
@@ -228,8 +231,26 @@ blurconsole.search = (function () {
   }
 
   function _updateOptionPopover() {
-    if ($('#superQuery').length > 0) {
-      $('#superQuery').val(stateMap.$rowRecordOption);
+    var superQuery = $('#superQuery');
+    if (superQuery.length > 0) {
+      $.each(configMap.superQueryMap, function(key,value) {
+        superQuery.append('<option value="'+key+'">'+value+'</option>');
+      });
+      superQuery.val(stateMap.$rowRecordOption);
+    }
+    var user = $('#user');
+    if (user.length > 0) {
+      blurconsole.model.security.userNames(function(names) {
+        if(names.length === 0) {
+          user.closest('.form-group').remove();
+        } else {
+          user.append('<option value=""></option>');
+          $.each(names, function(index, name) {
+            user.append('<option>'+name+'</option>');
+          });
+          user.val(stateMap.$userOption);
+        }
+      });
     }
   }
 
@@ -240,10 +261,12 @@ blurconsole.search = (function () {
         resendSearch = true;
       } else {
         $('#superQuery').val(stateMap.$rowRecordOption);
+        $('#user').val(stateMap.$userOption);
         return false;
       }
     }
     stateMap.$rowRecordOption = $('#superQuery').val();
+    stateMap.$userOption = $('#user').val();
     if (resendSearch) {
       _sendSearch();
     }
@@ -260,12 +283,13 @@ blurconsole.search = (function () {
       _tab: {
         query: encodeURIComponent(stateMap.$currentQuery),
         table: stateMap.$currentTable,
-        rr: stateMap.$rowRecordOption
+        rr: stateMap.$rowRecordOption,
+        user: stateMap.$userOption
       }
     });
     _drawResultHolders();
     jqueryMap.$countHolder.html('');
-    blurconsole.model.search.runSearch(stateMap.$currentQuery, stateMap.$currentTable, {start:
0, fetch: 10, rowRecordOption: stateMap.$rowRecordOption});
+    blurconsole.model.search.runSearch(stateMap.$currentQuery, stateMap.$currentTable, {start:
0, fetch: 10, rowRecordOption: stateMap.$rowRecordOption, securityUser: stateMap.$userOption});
   }
 
   function _getMoreData(evt) {
@@ -436,7 +460,7 @@ blurconsole.search = (function () {
     jqueryMap.facetModal.modal();
   }
 
-    //--------------------------------- Public API ------------------------------------------
+  //--------------------------------- Public API ------------------------------------------
   function initModule($container) {
     $container.load(configMap.view, function() {
       stateMap.$container = $container;
@@ -454,6 +478,7 @@ blurconsole.search = (function () {
         stateMap.$currentTable = startupMap._tab.table;
         jqueryMap.$tableField.val(stateMap.$currentTable);
         stateMap.$rowRecordOption = startupMap._tab.rr;
+        stateMap.$userOption = startupMap._tab.user;
       }
 
       _updateOptionDisplay();


Mime
View raw message