aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-10-17 17:10:53 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-10-17 17:10:53 +0200
commit6109d68e1f26c53eb6e3a0c3c126ec18a33ed2c6 (patch)
tree228dd5199e0098b25776ce3ea1a381a602655c49
parent5c3ae07af1b94d93add71e5aeaa895159880e5af (diff)
downloadsonarqube-6109d68e1f26c53eb6e3a0c3c126ec18a33ed2c6.tar.gz
sonarqube-6109d68e1f26c53eb6e3a0c3c126ec18a33ed2c6.zip
Revert "fixup! SONAR-7590 Redirect to requested page with identity provider"
This reverts commit 5c3ae07af1b94d93add71e5aeaa895159880e5af.
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2ContextFactory.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2Redirection.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java6
3 files changed, 4 insertions, 9 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2ContextFactory.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2ContextFactory.java
index b8fdec59f8c..ac051e4ab4a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2ContextFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2ContextFactory.java
@@ -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);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2Redirection.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2Redirection.java
index 18619fecda3..c66d54e7ae5 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2Redirection.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/OAuth2Redirection.java
@@ -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) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java
index 8bd30b6cb1d..90322fbfb50 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2ContextFactoryTest.java
@@ -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();