From 3a53422478867ba71c03b38e8d3f9cfa2560f35d Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Fri, 26 Jan 2024 11:24:00 -0700 Subject: [PATCH] Fix Failing Test Closes gh-14467 --- ...elLogoutReactiveAuthenticationManager.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/web/server/OidcBackChannelLogoutReactiveAuthenticationManager.java b/config/src/main/java/org/springframework/security/config/web/server/OidcBackChannelLogoutReactiveAuthenticationManager.java index 1cd87fc830..46e4c44206 100644 --- a/config/src/main/java/org/springframework/security/config/web/server/OidcBackChannelLogoutReactiveAuthenticationManager.java +++ b/config/src/main/java/org/springframework/security/config/web/server/OidcBackChannelLogoutReactiveAuthenticationManager.java @@ -85,17 +85,14 @@ final class OidcBackChannelLogoutReactiveAuthenticationManager implements Reacti private Mono decode(ClientRegistration registration, String token) { ReactiveJwtDecoder logoutTokenDecoder = this.logoutTokenDecoderFactory.createDecoder(registration); - try { - return logoutTokenDecoder.decode(token); - } - catch (BadJwtException failed) { - OAuth2Error error = new OAuth2Error(OAuth2ErrorCodes.INVALID_REQUEST, failed.getMessage(), - "https://openid.net/specs/openid-connect-backchannel-1_0.html#Validation"); - return Mono.error(new OAuth2AuthenticationException(error, failed)); - } - catch (Exception failed) { - return Mono.error(new AuthenticationServiceException(failed.getMessage(), failed)); - } + return logoutTokenDecoder.decode(token).onErrorResume(Exception.class, (ex) -> { + if (ex instanceof BadJwtException) { + OAuth2Error error = new OAuth2Error(OAuth2ErrorCodes.INVALID_REQUEST, ex.getMessage(), + "https://openid.net/specs/openid-connect-backchannel-1_0.html#Validation"); + return Mono.error(new OAuth2AuthenticationException(error, ex)); + } + return Mono.error(new AuthenticationServiceException(ex.getMessage(), ex)); + }); } /**