ServerAuthenticationSuccessHandler.success->onAuthenticationSuccess
Fixes gh-4618
This commit is contained in:
parent
247f737bc8
commit
78d2069c46
|
@ -88,7 +88,7 @@ public class AuthenticationWebFilter implements WebFilter {
|
|||
securityContext.setAuthentication(authentication);
|
||||
return this.serverSecurityContextRepository.save(exchange, securityContext)
|
||||
.then(this.serverAuthenticationSuccessHandler
|
||||
.success(authentication, webFilterExchange));
|
||||
.onAuthenticationSuccess(authentication, webFilterExchange));
|
||||
}
|
||||
|
||||
public void setServerSecurityContextRepository(
|
||||
|
|
|
@ -43,7 +43,7 @@ public class RedirectServerAuthenticationSuccessHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> success(Authentication authentication, WebFilterExchange webFilterExchange) {
|
||||
public Mono<Void> onAuthenticationSuccess(Authentication authentication, WebFilterExchange webFilterExchange) {
|
||||
ServerWebExchange exchange = webFilterExchange.getExchange();
|
||||
return this.serverRedirectStrategy.sendRedirect(exchange, this.location);
|
||||
}
|
||||
|
|
|
@ -25,5 +25,5 @@ import reactor.core.publisher.Mono;
|
|||
* @since 5.0
|
||||
*/
|
||||
public interface ServerAuthenticationSuccessHandler {
|
||||
Mono<Void> success(Authentication authentication, WebFilterExchange webFilterExchange);
|
||||
Mono<Void> onAuthenticationSuccess(Authentication authentication, WebFilterExchange webFilterExchange);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import reactor.core.publisher.Mono;
|
|||
public class WebFilterChainServerAuthenticationSuccessHandler
|
||||
implements ServerAuthenticationSuccessHandler {
|
||||
@Override
|
||||
public Mono<Void> success(Authentication authentication, WebFilterExchange webFilterExchange) {
|
||||
public Mono<Void> onAuthenticationSuccess(Authentication authentication, WebFilterExchange webFilterExchange) {
|
||||
ServerWebExchange exchange = webFilterExchange.getExchange();
|
||||
return webFilterExchange.getChain().filter(exchange);
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class AuthenticationWebFilterTests {
|
|||
Mono<Authentication> authentication = Mono.just(new TestingAuthenticationToken("test", "this", "ROLE_USER"));
|
||||
when(this.authenticationConverter.apply(any())).thenReturn(authentication);
|
||||
when(this.authenticationManager.authenticate(any())).thenReturn(authentication);
|
||||
when(this.successHandler.success(any(),any())).thenReturn(Mono.empty());
|
||||
when(this.successHandler.onAuthenticationSuccess(any(),any())).thenReturn(Mono.empty());
|
||||
when(this.serverSecurityContextRepository.save(any(),any())).thenAnswer( a -> Mono.just(a.getArguments()[0]));
|
||||
|
||||
WebTestClient client = WebTestClientBuilder
|
||||
|
@ -198,7 +198,7 @@ public class AuthenticationWebFilterTests {
|
|||
.expectStatus().isOk()
|
||||
.expectBody().isEmpty();
|
||||
|
||||
verify(this.successHandler).success(eq(authentication.block()), any());
|
||||
verify(this.successHandler).onAuthenticationSuccess(eq(authentication.block()), any());
|
||||
verify(this.serverSecurityContextRepository).save(any(), any());
|
||||
verifyZeroInteractions(this.failureHandler);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class RedirectServerAuthenticationSuccessHandlerTests {
|
|||
|
||||
@Test
|
||||
public void successWhenNoSubscribersThenNoActions() {
|
||||
this.handler.success(this.authentication, new WebFilterExchange(this.exchange,
|
||||
this.handler.onAuthenticationSuccess(this.authentication, new WebFilterExchange(this.exchange,
|
||||
this.chain));
|
||||
|
||||
verifyZeroInteractions(this.exchange);
|
||||
|
@ -76,7 +76,7 @@ public class RedirectServerAuthenticationSuccessHandlerTests {
|
|||
public void successWhenSubscribeThenStatusAndLocationSet() {
|
||||
this.exchange = MockServerHttpRequest.get("/").toExchange();
|
||||
|
||||
this.handler.success(this.authentication, new WebFilterExchange(this.exchange,
|
||||
this.handler.onAuthenticationSuccess(this.authentication, new WebFilterExchange(this.exchange,
|
||||
this.chain)).block();
|
||||
|
||||
assertThat(this.exchange.getResponse().getStatusCode()).isEqualTo(
|
||||
|
@ -91,7 +91,7 @@ public class RedirectServerAuthenticationSuccessHandlerTests {
|
|||
this.handler.setServerRedirectStrategy(this.serverRedirectStrategy);
|
||||
this.exchange = MockServerHttpRequest.get("/").toExchange();
|
||||
|
||||
assertThat(this.handler.success(this.authentication, new WebFilterExchange(this.exchange,
|
||||
assertThat(this.handler.onAuthenticationSuccess(this.authentication, new WebFilterExchange(this.exchange,
|
||||
this.chain))).isEqualTo(result);
|
||||
verify(this.serverRedirectStrategy).sendRedirect(any(), eq(this.location));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue