You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2019/05/14 03:56:55 UTC

[ranger] branch master updated: RANGER-2423: Ranger KnoxSSO authentication in Ranger HA environment

This is an automated email from the ASF dual-hosted git repository.

pradeep pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/master by this push:
     new 11a88bd  RANGER-2423: Ranger KnoxSSO authentication in Ranger HA environment
11a88bd is described below

commit 11a88bdc6317ee522d4173a0044d4f5738fe944d
Author: Pradeep <pr...@apache.org>
AuthorDate: Mon May 13 18:29:43 2019 +0530

    RANGER-2423: Ranger KnoxSSO authentication in Ranger HA environment
---
 .../web/filter/RangerSSOAuthenticationFilter.java  | 79 +++++++++++-----------
 1 file changed, 40 insertions(+), 39 deletions(-)

diff --git a/security-admin/src/main/java/org/apache/ranger/security/web/filter/RangerSSOAuthenticationFilter.java b/security-admin/src/main/java/org/apache/ranger/security/web/filter/RangerSSOAuthenticationFilter.java
index 8a6c39b..c3fbe9c 100644
--- a/security-admin/src/main/java/org/apache/ranger/security/web/filter/RangerSSOAuthenticationFilter.java
+++ b/security-admin/src/main/java/org/apache/ranger/security/web/filter/RangerSSOAuthenticationFilter.java
@@ -235,45 +235,46 @@ public class RangerSSOAuthenticationFilter implements Filter {
 		}
 	}
 
-        private String constructForwardableURL(HttpServletRequest httpRequest){
-                String xForwardedProto = "";
-                String xForwardedHost = "";
-                String xForwardedContext = "";
-                Enumeration<?> names = httpRequest.getHeaderNames();
-                while (names.hasMoreElements()) {
-                        String name = (String) names.nextElement();
-                        Enumeration<?> values = httpRequest.getHeaders(name);
-                        String value = "";
-                        if (values != null) {
-                                while (values.hasMoreElements()) {
-                                        value = (String) values.nextElement();
-                                }
-                        }
-                        if (StringUtils.trimToNull(name) != null
-                                        && StringUtils.trimToNull(value) != null) {
-                                if (name.equalsIgnoreCase("x-forwarded-proto")) {
-                                        xForwardedProto = value;
-                                } else if (name.equalsIgnoreCase("x-forwarded-host")) {
-                                        xForwardedHost = value;
-                                } else if (name.equalsIgnoreCase("x-forwarded-context")) {
-                                        xForwardedContext = value;
-                                }
-                        }
-                }
-                if (xForwardedHost.contains(",")) {
-                    if(LOG.isDebugEnabled()) {
-                        LOG.debug("xForwardedHost value is " + xForwardedHost + " it contains multiple hosts, selecting the first host.");
-                    }
-                    xForwardedHost = xForwardedHost.split(",")[0].trim();
-                }
-                String xForwardedURL = "";
-                if (StringUtils.trimToNull(xForwardedProto) != null && StringUtils.trimToNull(xForwardedHost) != null && StringUtils.trimToNull(xForwardedContext) != null) {
-                        xForwardedURL = xForwardedProto + "://" + xForwardedHost
-                                        + xForwardedContext + PROXY_RANGER_URL_PATH
-                                        + httpRequest.getRequestURI();
-                }
-                return xForwardedURL;
-        }
+	private String constructForwardableURL(HttpServletRequest httpRequest) {
+		String xForwardedProto = "";
+		String xForwardedHost = "";
+		String xForwardedContext = "";
+		Enumeration<?> names = httpRequest.getHeaderNames();
+		while (names.hasMoreElements()) {
+			String name = (String) names.nextElement();
+			Enumeration<?> values = httpRequest.getHeaders(name);
+			String value = "";
+			if (values != null) {
+				while (values.hasMoreElements()) {
+					value = (String) values.nextElement();
+				}
+			}
+			if (StringUtils.trimToNull(name) != null && StringUtils.trimToNull(value) != null) {
+				if (name.equalsIgnoreCase("x-forwarded-proto")) {
+					xForwardedProto = value;
+				} else if (name.equalsIgnoreCase("x-forwarded-host")) {
+					xForwardedHost = value;
+				} else if (name.equalsIgnoreCase("x-forwarded-context")) {
+					xForwardedContext = value;
+				}
+			}
+		}
+		if (xForwardedHost.contains(",")) {
+			if (LOG.isDebugEnabled()) {
+				LOG.debug("xForwardedHost value is " + xForwardedHost + " it contains multiple hosts, selecting the first host.");
+			}
+			xForwardedHost = xForwardedHost.split(",")[0].trim();
+		}
+		String xForwardedURL = "";
+		if (StringUtils.trimToNull(xForwardedProto) != null && StringUtils.trimToNull(xForwardedHost) != null) {
+			if (StringUtils.trimToNull(xForwardedContext) != null) {
+				xForwardedURL = xForwardedProto + "://" + xForwardedHost + xForwardedContext + PROXY_RANGER_URL_PATH + httpRequest.getRequestURI();
+			} else {
+				xForwardedURL = xForwardedProto + "://" + xForwardedHost + httpRequest.getRequestURI();
+			}
+		}
+		return xForwardedURL;
+	}
 
 	private Authentication getGrantedAuthority(Authentication authentication) {
 		UsernamePasswordAuthenticationToken result=null;