Skip to content

Commit 9608e48

Browse files
committed
replace servlet status code with HttpStatus in back-channel logout filters (spring-projects#17125)
Signed-off-by: Andrey Litvitski <[email protected]>
1 parent 07a50b4 commit 9608e48

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

config/src/main/java/org/springframework/security/config/web/server/OidcBackChannelLogoutWebFilter.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 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.
@@ -18,9 +18,9 @@
1818

1919
import java.util.Collections;
2020

21-
import jakarta.servlet.http.HttpServletResponse;
2221
import org.apache.commons.logging.Log;
2322
import org.apache.commons.logging.LogFactory;
23+
import org.springframework.http.HttpStatus;
2424
import reactor.core.publisher.Mono;
2525

2626
import org.springframework.core.ResolvableType;
@@ -47,6 +47,7 @@
4747
* A filter for the Client-side OIDC Back-Channel Logout endpoint
4848
*
4949
* @author Josh Cummings
50+
* @author Andrey Litvitski
5051
* @since 6.2
5152
* @see <a target="_blank" href=
5253
* "https://openid.net/specs/openid-connect-backchannel-1_0.html">OIDC Back-Channel Logout
@@ -108,7 +109,7 @@ public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
108109

109110
private Mono<Void> handleAuthenticationFailure(ServerWebExchange exchange, Exception ex) {
110111
this.logger.debug("Failed to process OIDC Back-Channel Logout", ex);
111-
exchange.getResponse().setRawStatusCode(HttpServletResponse.SC_BAD_REQUEST);
112+
exchange.getResponse().setRawStatusCode(HttpStatus.BAD_REQUEST.value());
112113
return this.errorHttpMessageConverter.write(Mono.just(oauth2Error(ex)), ResolvableType.forClass(Object.class),
113114
ResolvableType.forClass(Object.class), MediaType.APPLICATION_JSON, exchange.getRequest(),
114115
exchange.getResponse(), Collections.emptyMap());

config/src/main/java/org/springframework/security/config/web/server/OidcBackChannelServerLogoutHandler.java

+4-3
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.
@@ -22,9 +22,9 @@
2222
import java.util.Map;
2323
import java.util.concurrent.atomic.AtomicInteger;
2424

25-
import jakarta.servlet.http.HttpServletResponse;
2625
import org.apache.commons.logging.Log;
2726
import org.apache.commons.logging.LogFactory;
27+
import org.springframework.http.HttpStatus;
2828
import reactor.core.publisher.Mono;
2929

3030
import org.springframework.core.ResolvableType;
@@ -54,6 +54,7 @@
5454
* Back-Channel Logout Token and invalidates each one.
5555
*
5656
* @author Josh Cummings
57+
* @author Andrey Litvitski
5758
* @since 6.4
5859
* @see <a target="_blank" href=
5960
* "https://openid.net/specs/openid-connect-backchannel-1_0.html">OIDC Back-Channel Logout
@@ -170,7 +171,7 @@ private OAuth2Error oauth2Error(Collection<?> errors) {
170171
}
171172

172173
private Mono<Void> handleLogoutFailure(ServerWebExchange exchange, OAuth2Error error) {
173-
exchange.getResponse().setRawStatusCode(HttpServletResponse.SC_BAD_REQUEST);
174+
exchange.getResponse().setRawStatusCode(HttpStatus.BAD_REQUEST.value());
174175
return this.errorHttpMessageConverter.write(Mono.just(error), ResolvableType.forClass(Object.class),
175176
ResolvableType.forClass(Object.class), MediaType.APPLICATION_JSON, exchange.getRequest(),
176177
exchange.getResponse(), Collections.emptyMap());

0 commit comments

Comments
 (0)