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
@@ -69,7 +69,7 @@ public class AuthorizationManagerFactoryTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=ott&factor.reason=missing"));
// @formatter:on
}
@@ -80,7 +80,7 @@ public class AuthorizationManagerFactoryTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=password&factor.reason=missing"));
// @formatter:on
}
@@ -91,7 +91,7 @@ public class AuthorizationManagerFactoryTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"));
// @formatter:on
}
@@ -101,7 +101,7 @@ public class AuthorizationManagerFactoryTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login"));
.andExpect(redirectedUrl("/login"));
// @formatter:on
}
@@ -69,7 +69,7 @@ public class EnableGlobalMultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=ott&factor.reason=missing"));
// @formatter:on
}
@@ -80,7 +80,7 @@ public class EnableGlobalMultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=password&factor.reason=missing"));
// @formatter:on
}
@@ -91,7 +91,7 @@ public class EnableGlobalMultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"));
// @formatter:on
}
@@ -101,7 +101,7 @@ public class EnableGlobalMultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login"));
.andExpect(redirectedUrl("/login"));
// @formatter:on
}
@@ -69,7 +69,7 @@ public class MultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=ott&factor.reason=missing"));
// @formatter:on
}
@@ -80,7 +80,7 @@ public class MultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=password&factor.reason=missing"));
// @formatter:on
}
@@ -91,7 +91,7 @@ public class MultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"));
// @formatter:on
}
@@ -101,7 +101,7 @@ public class MultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login"));
.andExpect(redirectedUrl("/login"));
// @formatter:on
}
@@ -69,7 +69,7 @@ public class MultipleAuthorizationRulesConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=ott&factor.reason=missing"));
// @formatter:on
}
@@ -80,7 +80,7 @@ public class MultipleAuthorizationRulesConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=password&factor.reason=missing"));
// @formatter:on
}
@@ -91,7 +91,7 @@ public class MultipleAuthorizationRulesConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"));
// @formatter:on
}
@@ -101,7 +101,7 @@ public class MultipleAuthorizationRulesConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login"));
.andExpect(redirectedUrl("/login"));
// @formatter:on
}
@@ -58,7 +58,7 @@ public class AdminMfaAuthorizationManagerConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.type=password&factor.reason=missing&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=ott&factor.type=password&factor.reason=missing&factor.reason=missing"));
// @formatter:on
}
@@ -58,7 +58,7 @@ public class RequiredAuthoritiesAuthorizationManagerConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.type=password&factor.reason=missing&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=ott&factor.type=password&factor.reason=missing&factor.reason=missing"));
// @formatter:on
}
@@ -69,7 +69,7 @@ public class ReauthenticationTests {
// @formatter:off
this.mockMvc.perform(get("/profile"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=ott&factor.reason=missing"));
// @formatter:on
}
@@ -59,7 +59,7 @@ public class SelectiveMfaConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/admin/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrlPattern("http://localhost/login?*"));
.andExpect(redirectedUrlPattern("/login?*"));
// @formatter:on
}
@@ -81,7 +81,7 @@ public class SelectiveMfaConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/admin/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"));
.andExpect(redirectedUrl("/login?factor.type=ott&factor.reason=missing"));
// @formatter:on
}
@@ -92,7 +92,7 @@ public class SelectiveMfaConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/user/settings/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrlPattern("http://localhost/login?*"));
.andExpect(redirectedUrlPattern("/login?*"));
// @formatter:on
}
@@ -63,7 +63,7 @@ public class ValidDurationConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/admin/").with(admin(Duration.ofMinutes(31))))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrlPattern("http://localhost/login?*"));
.andExpect(redirectedUrlPattern("/login?*"));
// @formatter:on
}
@@ -84,7 +84,7 @@ public class ValidDurationConfigurationTests {
// @formatter:off
this.mockMvc.perform(get("/user/settings").with(user(Duration.ofMinutes(61))))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrlPattern("http://localhost/login?*"));
.andExpect(redirectedUrlPattern("/login?*"));
// @formatter:on
}
@@ -68,7 +68,7 @@ class AuthorizationManagerFactoryTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=ott&factor.reason=missing"))
// @formatter:on
}
@@ -81,7 +81,7 @@ class AuthorizationManagerFactoryTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=password&factor.reason=missing"))
// @formatter:on
}
@@ -94,7 +94,7 @@ class AuthorizationManagerFactoryTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"))
// @formatter:on
}
@@ -106,7 +106,7 @@ class AuthorizationManagerFactoryTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login"))
// @formatter:on
}
@@ -66,7 +66,7 @@ class EnableGlobalMultiFactorAuthenticationConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=ott&factor.reason=missing"))
// @formatter:on
}
@@ -78,7 +78,7 @@ class EnableGlobalMultiFactorAuthenticationConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=password&factor.reason=missing"))
// @formatter:on
}
@@ -90,7 +90,7 @@ class EnableGlobalMultiFactorAuthenticationConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"))
// @formatter:on
}
@@ -101,7 +101,7 @@ class EnableGlobalMultiFactorAuthenticationConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login"))
// @formatter:on
}
@@ -66,7 +66,7 @@ class MultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=ott&factor.reason=missing"))
// @formatter:on
}
@@ -78,7 +78,7 @@ class MultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=password&factor.reason=missing"))
// @formatter:on
}
@@ -90,7 +90,7 @@ class MultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"))
// @formatter:on
}
@@ -101,7 +101,7 @@ class MultiFactorAuthenticationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login"))
// @formatter:on
}
@@ -66,7 +66,7 @@ class MultipleAuthorizationRulesConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=ott&factor.reason=missing"))
// @formatter:on
}
@@ -78,7 +78,7 @@ class MultipleAuthorizationRulesConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=password&factor.reason=missing"))
// @formatter:on
}
@@ -90,7 +90,7 @@ class MultipleAuthorizationRulesConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=password&factor.type=ott&factor.reason=missing&factor.reason=missing"))
// @formatter:on
}
@@ -101,7 +101,7 @@ class MultipleAuthorizationRulesConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login"))
// @formatter:on
}
@@ -55,7 +55,7 @@ class AdminMfaAuthorizationManagerConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(get("/"))
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("http://localhost/login?factor.type=ott&factor.type=password&factor.reason=missing&factor.reason=missing"))
.andExpect(redirectedUrl("/login?factor.type=ott&factor.type=password&factor.reason=missing&factor.reason=missing"))
// @formatter:on
}
@@ -68,7 +68,7 @@ class ReauthenticationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/profile"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=ott&factor.reason=missing"))
// @formatter:on
}
@@ -56,7 +56,7 @@ class SelectiveMfaConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/admin/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrlPattern("http://localhost/login?*"))
.andExpect(MockMvcResultMatchers.redirectedUrlPattern("/login?*"))
// @formatter:on
}
@@ -86,7 +86,7 @@ class SelectiveMfaConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/admin/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrl("http://localhost/login?factor.type=ott&factor.reason=missing"))
.andExpect(MockMvcResultMatchers.redirectedUrl("/login?factor.type=ott&factor.reason=missing"))
// @formatter:on
}
@@ -100,7 +100,7 @@ class SelectiveMfaConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/user/settings/"))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrlPattern("http://localhost/login?*"))
.andExpect(MockMvcResultMatchers.redirectedUrlPattern("/login?*"))
// @formatter:on
}
@@ -60,7 +60,7 @@ class ValidDurationConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/admin/").with(admin(Duration.ofMinutes(31))))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrlPattern("http://localhost/login?*"))
.andExpect(MockMvcResultMatchers.redirectedUrlPattern("/login?*"))
// @formatter:on
}
@@ -85,7 +85,7 @@ class ValidDurationConfigurationTests {
// @formatter:off
this.mockMvc!!.perform(MockMvcRequestBuilders.get("/user/settings").with(user(Duration.ofMinutes(61))))
.andExpect(MockMvcResultMatchers.status().is3xxRedirection())
.andExpect(MockMvcResultMatchers.redirectedUrlPattern("http://localhost/login?*"))
.andExpect(MockMvcResultMatchers.redirectedUrlPattern("/login?*"))
// @formatter:on
}