1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Favor Relative Redirects by Default

Closes gh-16300
This commit is contained in:
Josh Cummings
2025-10-20 09:57:06 -06:00
parent d5d7fd414d
commit 9c7b34a48b
45 changed files with 126 additions and 131 deletions
@@ -85,7 +85,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
private boolean useForward = false;
private boolean favorRelativeUris = false;
private boolean favorRelativeUris = true;
private final RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
@@ -105,6 +105,7 @@ public class LoginUrlAuthenticationEntryPointTests {
.build();
MockHttpServletResponse response = new MockHttpServletResponse();
LoginUrlAuthenticationEntryPoint ep = new LoginUrlAuthenticationEntryPoint("/hello");
ep.setFavorRelativeUris(false);
ep.setPortMapper(new PortMapperImpl());
ep.setForceHttps(true);
ep.setPortMapper(new PortMapperImpl());
@@ -130,12 +131,13 @@ public class LoginUrlAuthenticationEntryPointTests {
MockHttpServletRequest request = get().requestUri("/bigWebApp", "/some_path", null).build();
MockHttpServletResponse response = new MockHttpServletResponse();
ep.commence(request, response, null);
assertThat(response.getRedirectedUrl()).isEqualTo("http://localhost/bigWebApp/hello");
assertThat(response.getRedirectedUrl()).isEqualTo("/bigWebApp/hello");
}
@Test
public void testOperationWhenHttpsRequestsButHttpsPortUnknown() throws Exception {
LoginUrlAuthenticationEntryPoint ep = new LoginUrlAuthenticationEntryPoint("/hello");
ep.setFavorRelativeUris(false);
ep.setForceHttps(true);
ep.afterPropertiesSet();
MockHttpServletRequest request = get("http://localhost:8888").requestUri("/bigWebApp", "/some_path", null)