diff --git a/config/src/main/java/org/springframework/security/config/web/server/HttpSecurity.java b/config/src/main/java/org/springframework/security/config/web/server/HttpSecurity.java index 7a8264c0a5..43f92ec83c 100644 --- a/config/src/main/java/org/springframework/security/config/web/server/HttpSecurity.java +++ b/config/src/main/java/org/springframework/security/config/web/server/HttpSecurity.java @@ -34,7 +34,7 @@ import org.springframework.security.web.server.authentication.AuthenticationEntr import org.springframework.security.web.server.authentication.AuthenticationFailureHandler; import org.springframework.security.web.server.authentication.AuthenticationWebFilter; import org.springframework.security.web.server.authentication.RedirectServerAuthenticationEntryPoint; -import org.springframework.security.web.server.authentication.RedirectAuthenticationSuccessHandler; +import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler; import org.springframework.security.web.server.authentication.logout.LogoutHandler; import org.springframework.security.web.server.authentication.logout.LogoutWebFilter; import org.springframework.security.web.server.authentication.logout.SecurityContextRepositoryLogoutHandler; @@ -435,7 +435,7 @@ public class HttpSecurity { authenticationFilter.setRequiresAuthenticationMatcher(this.requiresAuthenticationMatcher); authenticationFilter.setAuthenticationFailureHandler(this.authenticationFailureHandler); authenticationFilter.setAuthenticationConverter(new ServerFormLoginAuthenticationConverter()); - authenticationFilter.setAuthenticationSuccessHandler(new RedirectAuthenticationSuccessHandler("/")); + authenticationFilter.setServerAuthenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/")); authenticationFilter.setSecurityContextServerRepository(this.securityContextServerRepository); http.addFilterAt(authenticationFilter, SecurityWebFiltersOrder.FORM_LOGIN); } diff --git a/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationWebFilter.java b/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationWebFilter.java index a33a6eec16..87211e2d6b 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationWebFilter.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationWebFilter.java @@ -45,7 +45,7 @@ public class AuthenticationWebFilter implements WebFilter { private final ReactiveAuthenticationManager authenticationManager; - private AuthenticationSuccessHandler authenticationSuccessHandler = new WebFilterChainAuthenticationSuccessHandler(); + private ServerAuthenticationSuccessHandler serverAuthenticationSuccessHandler = new WebFilterChainServerAuthenticationSuccessHandler(); private Function> authenticationConverter = new ServerHttpBasicAuthenticationConverter(); @@ -87,7 +87,8 @@ public class AuthenticationWebFilter implements WebFilter { SecurityContextImpl securityContext = new SecurityContextImpl(); securityContext.setAuthentication(authentication); return this.securityContextServerRepository.save(exchange, securityContext) - .then(this.authenticationSuccessHandler.success(authentication, webFilterExchange)); + .then(this.serverAuthenticationSuccessHandler + .success(authentication, webFilterExchange)); } public void setSecurityContextServerRepository( @@ -96,8 +97,8 @@ public class AuthenticationWebFilter implements WebFilter { this.securityContextServerRepository = securityContextServerRepository; } - public void setAuthenticationSuccessHandler(AuthenticationSuccessHandler authenticationSuccessHandler) { - this.authenticationSuccessHandler = authenticationSuccessHandler; + public void setServerAuthenticationSuccessHandler(ServerAuthenticationSuccessHandler serverAuthenticationSuccessHandler) { + this.serverAuthenticationSuccessHandler = serverAuthenticationSuccessHandler; } public void setAuthenticationConverter(Function> authenticationConverter) { diff --git a/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandler.java b/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandler.java similarity index 90% rename from webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandler.java rename to webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandler.java index 9de4c74954..d42740965b 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandler.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandler.java @@ -30,14 +30,15 @@ import java.net.URI; * @author Rob Winch * @since 5.0 */ -public class RedirectAuthenticationSuccessHandler implements AuthenticationSuccessHandler { +public class RedirectServerAuthenticationSuccessHandler + implements ServerAuthenticationSuccessHandler { private URI location = URI.create("/"); private ServerRedirectStrategy serverRedirectStrategy = new DefaultServerRedirectStrategy(); - public RedirectAuthenticationSuccessHandler() {} + public RedirectServerAuthenticationSuccessHandler() {} - public RedirectAuthenticationSuccessHandler(String location) { + public RedirectServerAuthenticationSuccessHandler(String location) { this.location = URI.create(location); } diff --git a/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationSuccessHandler.java b/webflux/src/main/java/org/springframework/security/web/server/authentication/ServerAuthenticationSuccessHandler.java similarity index 94% rename from webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationSuccessHandler.java rename to webflux/src/main/java/org/springframework/security/web/server/authentication/ServerAuthenticationSuccessHandler.java index 4f01dbd317..ac1a181697 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authentication/AuthenticationSuccessHandler.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authentication/ServerAuthenticationSuccessHandler.java @@ -24,6 +24,6 @@ import reactor.core.publisher.Mono; * @author Rob Winch * @since 5.0 */ -public interface AuthenticationSuccessHandler { +public interface ServerAuthenticationSuccessHandler { Mono success(Authentication authentication, WebFilterExchange webFilterExchange); } diff --git a/webflux/src/main/java/org/springframework/security/web/server/authentication/WebFilterChainAuthenticationSuccessHandler.java b/webflux/src/main/java/org/springframework/security/web/server/authentication/WebFilterChainServerAuthenticationSuccessHandler.java similarity index 88% rename from webflux/src/main/java/org/springframework/security/web/server/authentication/WebFilterChainAuthenticationSuccessHandler.java rename to webflux/src/main/java/org/springframework/security/web/server/authentication/WebFilterChainServerAuthenticationSuccessHandler.java index ff4866e879..a9c4e4aa3b 100644 --- a/webflux/src/main/java/org/springframework/security/web/server/authentication/WebFilterChainAuthenticationSuccessHandler.java +++ b/webflux/src/main/java/org/springframework/security/web/server/authentication/WebFilterChainServerAuthenticationSuccessHandler.java @@ -19,14 +19,14 @@ package org.springframework.security.web.server.authentication; import org.springframework.security.core.Authentication; import org.springframework.security.web.server.WebFilterExchange; import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.server.WebFilterChain; import reactor.core.publisher.Mono; /** * @author Rob Winch * @since 5.0 */ -public class WebFilterChainAuthenticationSuccessHandler implements AuthenticationSuccessHandler { +public class WebFilterChainServerAuthenticationSuccessHandler + implements ServerAuthenticationSuccessHandler { @Override public Mono success(Authentication authentication, WebFilterExchange webFilterExchange) { ServerWebExchange exchange = webFilterExchange.getExchange(); diff --git a/webflux/src/test/java/org/springframework/security/web/server/authentication/AuthenticationWebFilterTests.java b/webflux/src/test/java/org/springframework/security/web/server/authentication/AuthenticationWebFilterTests.java index 0a2c3c4f22..bfbad2ec64 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/authentication/AuthenticationWebFilterTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/authentication/AuthenticationWebFilterTests.java @@ -54,7 +54,7 @@ import static org.springframework.web.reactive.function.client.ExchangeFilterFun @RunWith(MockitoJUnitRunner.class) public class AuthenticationWebFilterTests { @Mock - private AuthenticationSuccessHandler successHandler; + private ServerAuthenticationSuccessHandler successHandler; @Mock private Function> authenticationConverter; @Mock @@ -69,7 +69,7 @@ public class AuthenticationWebFilterTests { @Before public void setup() { this.filter = new AuthenticationWebFilter(this.authenticationManager); - this.filter.setAuthenticationSuccessHandler(this.successHandler); + this.filter.setServerAuthenticationSuccessHandler(this.successHandler); this.filter.setAuthenticationConverter(this.authenticationConverter); this.filter.setSecurityContextServerRepository(this.securityContextServerRepository); this.filter.setAuthenticationFailureHandler(this.failureHandler); diff --git a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandlerTests.java b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandlerTests.java similarity index 95% rename from webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandlerTests.java rename to webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandlerTests.java index 3338c85377..42ec46c1ec 100644 --- a/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectAuthenticationSuccessHandlerTests.java +++ b/webflux/src/test/java/org/springframework/security/web/server/authentication/RedirectServerAuthenticationSuccessHandlerTests.java @@ -43,7 +43,7 @@ import static org.mockito.Mockito.when; * @since 5.0 */ @RunWith(MockitoJUnitRunner.class) -public class RedirectAuthenticationSuccessHandlerTests { +public class RedirectServerAuthenticationSuccessHandlerTests { @Mock private ServerWebExchange exchange; @@ -56,8 +56,8 @@ public class RedirectAuthenticationSuccessHandlerTests { private URI location = URI.create("/"); - private RedirectAuthenticationSuccessHandler handler = - new RedirectAuthenticationSuccessHandler(); + private RedirectServerAuthenticationSuccessHandler handler = + new RedirectServerAuthenticationSuccessHandler(); @Test(expected = IllegalArgumentException.class) public void constructorStringWhenNullLocationThenException() {