Fix login servlets when canonicalWebUrl is not set
Each login servlet knows enough about the incoming request to be able to not need the canonical web address for redirection purposes. In the case gerrit.canonicalWebUrl is not set, use the incoming request to build up the URL. This solution is a work-around for the fact that somewhere before 2.5 Colby broke the HttpServletRequest scope based version of the @CanonicalWebUrl provider. Because Guice cannot supply the request in some contexts we pass the request into the provider as an argument. Long term all of these authentication methods will be ejected into their own plugins and it will be possible to revisit how this configuration is handled. Change-Id: I0e00b89020860a02b5d6ea77da5c784f5f0bb1b8
This commit is contained in:
		| @@ -14,7 +14,6 @@ | ||||
|  | ||||
| package com.google.gerrit.httpd; | ||||
|  | ||||
| import com.google.gerrit.server.config.CanonicalWebUrl; | ||||
| import com.google.gerrit.server.config.CanonicalWebUrlProvider; | ||||
| import com.google.gerrit.server.config.GerritServerConfig; | ||||
| import com.google.inject.Inject; | ||||
| @@ -26,7 +25,7 @@ import org.eclipse.jgit.lib.Config; | ||||
|  | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
|  | ||||
| /** Sets {@link CanonicalWebUrl} to current HTTP request if not configured. */ | ||||
| /** Sets {@code CanonicalWebUrl} to current HTTP request if not configured. */ | ||||
| public class HttpCanonicalWebUrlProvider extends CanonicalWebUrlProvider { | ||||
|   private Provider<HttpServletRequest> requestProvider; | ||||
|  | ||||
| @@ -65,13 +64,7 @@ public class HttpCanonicalWebUrlProvider extends CanonicalWebUrlProvider { | ||||
|           throw noWeb; | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       final StringBuffer url = req.getRequestURL(); | ||||
|       url.setLength(url.length() - req.getServletPath().length()); | ||||
|       if (url.charAt(url.length() - 1) != '/') { | ||||
|         url.append('/'); | ||||
|       } | ||||
|       return url.toString(); | ||||
|       return CanonicalWebUrl.computeFromRequest(req); | ||||
|     } | ||||
|  | ||||
|     // We have no way of guessing our HTTP url. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Shawn Pearce
					Shawn Pearce