Skip to content

Commit 4048b2b

Browse files
therepanicjzheaux
authored andcommitted
Use HttpStatus in BackChannel Logout Filters
Closes gh-17125 Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
1 parent 86acba9 commit 4048b2b

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

Lines changed: 4 additions & 3 deletions
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,12 +18,12 @@
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;
2423
import reactor.core.publisher.Mono;
2524

2625
import org.springframework.core.ResolvableType;
26+
import org.springframework.http.HttpStatus;
2727
import org.springframework.http.MediaType;
2828
import org.springframework.http.codec.EncoderHttpMessageWriter;
2929
import org.springframework.http.codec.HttpMessageWriter;
@@ -48,6 +48,7 @@
4848
* A filter for the Client-side OIDC Back-Channel Logout endpoint
4949
*
5050
* @author Josh Cummings
51+
* @author Andrey Litvitski
5152
* @since 6.2
5253
* @see <a target="_blank" href=
5354
* "https://openid.net/specs/openid-connect-backchannel-1_0.html">OIDC Back-Channel Logout
@@ -107,7 +108,7 @@ public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
107108

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

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

Lines changed: 4 additions & 3 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.
@@ -22,13 +22,13 @@
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;
2827
import reactor.core.publisher.Mono;
2928

3029
import org.springframework.core.ResolvableType;
3130
import org.springframework.http.HttpHeaders;
31+
import org.springframework.http.HttpStatus;
3232
import org.springframework.http.MediaType;
3333
import org.springframework.http.ResponseEntity;
3434
import org.springframework.http.codec.EncoderHttpMessageWriter;
@@ -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.2
5859
* @see <a target="_blank" href=
5960
* "https://openid.net/specs/openid-connect-backchannel-1_0.html">OIDC Back-Channel Logout
@@ -154,7 +155,7 @@ private OAuth2Error oauth2Error(Collection<?> errors) {
154155
}
155156

156157
private Mono<Void> handleLogoutFailure(ServerWebExchange exchange, OAuth2Error error) {
157-
exchange.getResponse().setRawStatusCode(HttpServletResponse.SC_BAD_REQUEST);
158+
exchange.getResponse().setRawStatusCode(HttpStatus.BAD_REQUEST.value());
158159
return this.errorHttpMessageConverter.write(Mono.just(error), ResolvableType.forClass(Object.class),
159160
ResolvableType.forClass(Object.class), MediaType.APPLICATION_JSON, exchange.getRequest(),
160161
exchange.getResponse(), Collections.emptyMap());

0 commit comments

Comments
 (0)