Skip to content

Commit f5a036c

Browse files
Add setRedirectStrategy to OidcClientInitiatedServerLogoutSuccessHandler
Signed-off-by: Max Batischev <[email protected]>
1 parent 556a430 commit f5a036c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandler.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@
5151
*/
5252
public class OidcClientInitiatedServerLogoutSuccessHandler implements ServerLogoutSuccessHandler {
5353

54-
private final ServerRedirectStrategy redirectStrategy = new DefaultServerRedirectStrategy();
54+
private ServerRedirectStrategy redirectStrategy = new DefaultServerRedirectStrategy();
5555

5656
private final RedirectServerLogoutSuccessHandler serverLogoutSuccessHandler = new RedirectServerLogoutSuccessHandler();
5757

@@ -199,6 +199,17 @@ public void setRedirectUriResolver(Converter<RedirectUriParameters, Mono<String>
199199
this.redirectUriResolver = redirectUriResolver;
200200
}
201201

202+
/**
203+
* Set the {@link ServerRedirectStrategy} to use, default
204+
* {@link DefaultServerRedirectStrategy}
205+
* @param redirectStrategy {@link ServerRedirectStrategy}
206+
* @since 6.5
207+
*/
208+
public void setRedirectStrategy(ServerRedirectStrategy redirectStrategy) {
209+
Assert.notNull(redirectStrategy, "redirectStrategy cannot be null");
210+
this.redirectStrategy = redirectStrategy;
211+
}
212+
202213
/**
203214
* Parameters, required for redirect URI resolving.
204215
*

oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandlerTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -219,6 +219,11 @@ public void logoutWhenCustomRedirectUriResolverSetThenRedirects() {
219219
assertThat(redirectedUrl(this.exchange)).isEqualTo("https://test.com");
220220
}
221221

222+
@Test
223+
public void setRedirectStrategyWhenGivenNullThenThrowsException() {
224+
assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setRedirectStrategy(null));
225+
}
226+
222227
private String redirectedUrl(ServerWebExchange exchange) {
223228
return exchange.getResponse().getHeaders().getFirst("Location");
224229
}

0 commit comments

Comments
 (0)