]> source.dussan.org Git - sonarqube.git/commitdiff
Revert "fixup! SONAR-7590 Redirect to requested page with identity provider"
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 17 Oct 2017 15:10:53 +0000 (17:10 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 17 Oct 2017 15:10:53 +0000 (17:10 +0200)
This reverts commit 5c3ae07af1b94d93add71e5aeaa895159880e5af.

server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2ContextFactory.java
server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2Redirection.java
server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java

index b8fdec59f8c06b65cd43df89a9376ade47ddd9b2..ac051e4ab4ac2fa9df0aa18e05091657ace66193 100644 (file)
@@ -115,7 +115,7 @@ public class OAuth2ContextFactory {
     public void redirectToRequestedPage() {
       try {
         Optional<String> redirectTo = oAuthRedirection.getAndDelete(request, response);
-        getResponse().sendRedirect(redirectTo.orElse(server.getContextPath() + "/"));
+        getResponse().sendRedirect(server.getContextPath() + redirectTo.orElse("/"));
       } catch (IOException e) {
         throw new IllegalStateException("Fail to redirect to home", e);
       }
index 18619fecda3aa6753f9e05817d397cfd7be85e64..c66d54e7ae511500a7790d2b1471d791a5b4aa45 100644 (file)
@@ -31,11 +31,6 @@ import static org.sonar.server.authentication.Cookies.newCookieBuilder;
 public class OAuth2Redirection {
 
   private static final String REDIRECT_TO_COOKIE = "REDIRECT_TO";
-
-  /**
-   * The HTTP parameter that contains the path where the user should be redirect to.
-   * Please note that the web context is included.
-   */
   private static final String RETURN_TO_PARAMETER = "return_to";
 
   public void create(HttpServletRequest request, HttpServletResponse response) {
index 8bd30b6cb1db163d7c5dfd3be7802b55cc4d3442..90322fbfb507fb010e7915ac58c0093499e51a87 100644 (file)
@@ -179,9 +179,9 @@ public class OAuth2ContextFactoryTest {
   }
 
   @Test
-  public void redirect_to_requested_page_doesnt_need_context() throws Exception {
-    when(oAuthRedirection.getAndDelete(request, response)).thenReturn(Optional.of("/sonarqube/settings"));
-    when(server.getContextPath()).thenReturn("/other");
+  public void redirect_to_requested_page_context() throws Exception {
+    when(oAuthRedirection.getAndDelete(request, response)).thenReturn(Optional.of("/settings"));
+    when(server.getContextPath()).thenReturn("/sonarqube");
     OAuth2IdentityProvider.CallbackContext callback = newCallbackContext();
 
     callback.redirectToRequestedPage();