ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [1/2] ambari git commit: AMBARI-19664. Log Search: Snapshot tour fix & configurable CORS filter (oleewere)
Date Mon, 23 Jan 2017 12:38:27 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 09c1894f7 -> b6b43785e


AMBARI-19664. Log Search: Snapshot tour fix & configurable CORS filter (oleewere)

Change-Id: I763e9ac69d1058f85a2be3a2aa036e008ff89b95


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9bd8b7f2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9bd8b7f2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9bd8b7f2

Branch: refs/heads/trunk
Commit: 9bd8b7f2ff1c7d2ca2cfd4bf8b0833a1bec98bb9
Parents: 09c1894
Author: oleewere <oleewere@gmail.com>
Authored: Sun Jan 22 22:29:19 2017 +0100
Committer: oleewere <oleewere@gmail.com>
Committed: Mon Jan 23 13:33:53 2017 +0100

----------------------------------------------------------------------
 .../conf/LogSearchHttpHeaderConfig.java         | 70 ++++++++++++++++++++
 .../ambari/logsearch/conf/SecurityConfig.java   | 11 +++
 .../web/filters/LogsearchCorsFilter.java        | 59 +++++++++++++++++
 .../src/main/webapp/scripts/utils/Tour.js       | 30 ++++-----
 4 files changed, 154 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9bd8b7f2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/LogSearchHttpHeaderConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/LogSearchHttpHeaderConfig.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/LogSearchHttpHeaderConfig.java
new file mode 100644
index 0000000..cb8c097
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/LogSearchHttpHeaderConfig.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.conf;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class LogSearchHttpHeaderConfig {
+
+  @Value("${logsearch.http.header.access-control-allow-origin:*}")
+  private String accessControlAllowOrigin;
+
+  @Value("${logsearch.http.header.access-control-allow-headers:origin, content-type, accept,
authorization}")
+  private String accessControlAllowHeaders;
+
+  @Value("${logsearch.http.header.access-control-allow-credentials:true}")
+  private String accessControlAllowCredentials;
+
+  @Value("${logsearch.http.header.access-control-allow-methods:GET, POST, PUT, DELETE, OPTIONS,
HEAD}")
+  private String accessControlAllowMethods;
+
+  public String getAccessControlAllowOrigin() {
+    return accessControlAllowOrigin;
+  }
+
+  public void setAccessControlAllowOrigin(String accessControlAllowOrigin) {
+    this.accessControlAllowOrigin = accessControlAllowOrigin;
+  }
+
+  public String getAccessControlAllowHeaders() {
+    return accessControlAllowHeaders;
+  }
+
+  public void setAccessControlAllowHeaders(String accessControlAllowHeaders) {
+    this.accessControlAllowHeaders = accessControlAllowHeaders;
+  }
+
+  public String getAccessControlAllowCredentials() {
+    return accessControlAllowCredentials;
+  }
+
+  public void setAccessControlAllowCredentials(String accessControlAllowCredentials) {
+    this.accessControlAllowCredentials = accessControlAllowCredentials;
+  }
+
+  public String getAccessControlAllowMethods() {
+    return accessControlAllowMethods;
+  }
+
+  public void setAccessControlAllowMethods(String accessControlAllowMethods) {
+    this.accessControlAllowMethods = accessControlAllowMethods;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/9bd8b7f2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
index 115dcc3..b15ae43 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/conf/SecurityConfig.java
@@ -25,6 +25,7 @@ import org.apache.ambari.logsearch.web.authenticate.LogsearchAuthSuccessHandler;
 import org.apache.ambari.logsearch.web.authenticate.LogsearchLogoutSuccessHandler;
 import org.apache.ambari.logsearch.web.filters.LogsearchAuditLogsStateFilter;
 import org.apache.ambari.logsearch.web.filters.LogsearchAuthenticationEntryPoint;
+import org.apache.ambari.logsearch.web.filters.LogsearchCorsFilter;
 import org.apache.ambari.logsearch.web.filters.LogsearchKRBAuthenticationFilter;
 import org.apache.ambari.logsearch.web.filters.LogsearchJWTFilter;
 import org.apache.ambari.logsearch.web.filters.LogsearchSecurityContextFormationFilter;
@@ -46,6 +47,7 @@ import org.springframework.security.web.util.matcher.RequestMatcher;
 
 import javax.inject.Inject;
 import javax.inject.Named;
+import javax.servlet.Filter;
 import java.util.List;
 
 import static org.apache.ambari.logsearch.common.LogSearchConstants.LOGSEARCH_SESSION_ID;
@@ -58,6 +60,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
   private AuthPropsConfig authPropsConfig;
 
   @Inject
+  private LogSearchHttpHeaderConfig logSearchHttpHeaderConfig;
+
+  @Inject
   private SolrServiceLogPropsConfig solrServiceLogPropsConfig;
 
   @Inject
@@ -104,6 +109,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
       .addFilterAfter(logsearchUserConfigFilter(), LogsearchSecurityContextFormationFilter.class)
       .addFilterAfter(logsearchAuditLogFilter(), LogsearchSecurityContextFormationFilter.class)
       .addFilterAfter(logsearchServiceLogFilter(), LogsearchSecurityContextFormationFilter.class)
+      .addFilterBefore(corsFilter(), LogsearchSecurityContextFormationFilter.class)
       .addFilterBefore(logsearchJwtFilter(), LogsearchSecurityContextFormationFilter.class)
       .logout()
         .logoutUrl("/logout.html")
@@ -112,6 +118,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
   }
 
   @Bean
+  public LogsearchCorsFilter corsFilter() {
+    return new LogsearchCorsFilter(logSearchHttpHeaderConfig);
+  }
+
+  @Bean
   public LogsearchSecurityContextFormationFilter securityContextFormationFilter() {
     return new LogsearchSecurityContextFormationFilter();
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/9bd8b7f2/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchCorsFilter.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchCorsFilter.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchCorsFilter.java
new file mode 100644
index 0000000..f5e7bca
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/filters/LogsearchCorsFilter.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ambari.logsearch.web.filters;
+
+import org.apache.ambari.logsearch.conf.LogSearchHttpHeaderConfig;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class LogsearchCorsFilter implements Filter {
+
+  private LogSearchHttpHeaderConfig logSearchHttpHeaderConfig;
+
+  public LogsearchCorsFilter(LogSearchHttpHeaderConfig logSearchHttpHeaderConfig) {
+    this.logSearchHttpHeaderConfig = logSearchHttpHeaderConfig;
+  }
+
+  @Override
+  public void init(FilterConfig filterConfig) throws ServletException {
+  }
+
+  @Override
+  public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain
filterChain)
+    throws IOException, ServletException {
+    HttpServletResponse response = (HttpServletResponse) servletResponse;
+    response.setHeader("Access-Control-Allow-Origin", logSearchHttpHeaderConfig.getAccessControlAllowOrigin());
+    response.setHeader("Access-Control-Allow-Headers", logSearchHttpHeaderConfig.getAccessControlAllowHeaders());
+    response.setHeader("Access-Control-Allow-Credentials", logSearchHttpHeaderConfig.getAccessControlAllowCredentials());
+    response.setHeader("Access-Control-Allow-Methods", logSearchHttpHeaderConfig.getAccessControlAllowMethods());
+    filterChain.doFilter(servletRequest, servletResponse);
+  }
+
+  @Override
+  public void destroy() {
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/9bd8b7f2/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Tour.js
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Tour.js
b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Tour.js
index fff82ed..f9d093b 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Tour.js
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Tour.js
@@ -56,6 +56,10 @@ define(['require', 'tour'], function (require, TourJs) {
         content: "This filter allows you to filter the log data depending upon the component
selection. Include Component is again \"or\" condition and Exclude Component is \"and\" condition
between multiple selection.",
         placement: "bottom"
       }, {
+        element: $('[data-id="startStop"]').get(0),
+        content: "Snapshot helps you quickly see all logs generated while you reproduce an
issue. Click start, reproduce your issue, click stop and we'll load all logs that were produced
during that time frame.",
+        placement: "bottom"
+      }, {
         element: $('#r_Histogram').get(0),
         content: "Histogram displays comparative ratios of log severity during the currently
defined time filter.",
         placement: "top"
@@ -64,10 +68,6 @@ define(['require', 'tour'], function (require, TourJs) {
         content: "The Log Data default view displays consolidated for all hosts.",
         placement: "top",
       }, {
-        element: 'a[data-id="timerBtn"]',
-        content: "Snapshot helps you quickly see all logs generated while you reproduce an
issue. Click start, reproduce your issue, click stop and we'll load all logs that were produced
during that time frame.",
-        placement: "top"
-      }, {
         element: document.querySelectorAll('#r_BubbleTable')[1],
         content: "Expand the Log Data tree view and choose components to further refine your
diagnostics.",
         placement: "top",
@@ -146,8 +146,6 @@ define(['require', 'tour'], function (require, TourJs) {
         } else if (tour._state.current_step == 6) {
         } else if (tour._state.current_step == 7) {
           appendFingerAndOverlayDiv(tour._options.showFinger[tour._state.current_step]);
-        } else if (tour._state.current_step == 8) {
-          appendFingerAndOverlayDiv(tour._options.showFinger[tour._state.current_step]);
         } else if (tour._state.current_step == 9) {
           appendFingerAndOverlayDiv(tour._options.showFinger[tour._state.current_step]);
         } else if (tour._state.current_step == 10) {
@@ -257,26 +255,26 @@ define(['require', 'tour'], function (require, TourJs) {
       },
       8: {
         css: {
-          'top': '45px',
-          'left': '122px'
+          'top': '30px',
+          'left': '309px'
         },
-        handDirection: 'up',
+        handDirection: 'down',
         handClass: "up-down"
       },
       9: {
         css: {
           'top': '45px',
-          'left': '100px'
+          'left': '122px'
         },
-        appendIndex: 0,
-        handDirection: 'down',
+        handDirection: 'up',
         handClass: "up-down"
       },
       10: {
         css: {
-          'top': '30px',
-          'left': '309px'
+          'top': '45px',
+          'left': '100px'
         },
+        appendIndex: 0,
         handDirection: 'down',
         handClass: "up-down"
       },
@@ -396,13 +394,13 @@ define(['require', 'tour'], function (require, TourJs) {
         $('#r_BubbleTable input[value="H"]').click();
         removeFingerAndOverlayDiv();
       } else if (tour._state.current_step == 8) {
-        $('#r_BubbleTable li[data-parent="true"]').first().find('span[data-state="collapse"]').first().click();
-        $('#r_BubbleTable li[data-parent="true"]').first().find('a[data-type="C"]').first().removeClass('hidden');
         removeFingerAndOverlayDiv();
       } else if (tour._state.current_step == 9) {
+        $('#r_BubbleTable li[data-parent="true"]').first().find('span[data-state="collapse"]').first().click();
         $('#r_BubbleTable li[data-parent="true"]').first().find('a[data-type="C"]').first().removeClass('hidden');
         removeFingerAndOverlayDiv();
       } else if (tour._state.current_step == 10) {
+        $('#r_BubbleTable li[data-parent="true"]').first().find('a[data-type="C"]').first().removeClass('hidden');
         removeFingerAndOverlayDiv();
       } else if (tour._state.current_step == 11) {
         $('#r_BubbleTable input[value="T"]').click();


Mime
View raw message