From 8bb4387dc4dc2201423183b1e0243040469a0951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Thu, 6 Mar 2025 17:24:23 +0100 Subject: [PATCH] fix(oidc): Match the proper error type for invalid refresh token MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we do not use mas-oidc-client anymore, the error to match has changed. Signed-off-by: Kévin Commaille --- crates/matrix-sdk/src/client/futures.rs | 29 +++++++------------------ 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/crates/matrix-sdk/src/client/futures.rs b/crates/matrix-sdk/src/client/futures.rs index b239e06d5..562d12056 100644 --- a/crates/matrix-sdk/src/client/futures.rs +++ b/crates/matrix-sdk/src/client/futures.rs @@ -19,15 +19,9 @@ use std::{fmt::Debug, future::IntoFuture}; use eyeball::SharedObservable; #[cfg(not(target_arch = "wasm32"))] use eyeball::Subscriber; -#[cfg(feature = "experimental-oidc")] -use mas_oidc_client::{ - error::{ - Error as OidcClientError, ErrorBody as OidcErrorBody, HttpError as OidcHttpError, - TokenRefreshError, TokenRequestError, - }, - types::errors::ClientErrorCode, -}; use matrix_sdk_common::boxed_into_future; +#[cfg(feature = "experimental-oidc")] +use oauth2::{basic::BasicErrorResponseType, RequestTokenError}; use ruma::api::{client::error::ErrorKind, error::FromHttpResponseError, OutgoingRequest}; #[cfg(feature = "experimental-oidc")] use tracing::error; @@ -121,19 +115,12 @@ where #[cfg(feature = "experimental-oidc")] RefreshTokenError::Oidc(oidc_error) => { - match **oidc_error { - OidcError::Oidc(OidcClientError::TokenRefresh( - TokenRefreshError::Token(TokenRequestError::Http( - OidcHttpError { - body: - Some(OidcErrorBody { - error: ClientErrorCode::InvalidGrant, - .. - }), - .. - }, - )), - )) => { + match &**oidc_error { + OidcError::RefreshToken(RequestTokenError::ServerResponse( + error_response, + )) if *error_response.error() + == BasicErrorResponseType::InvalidGrant => + { error!("Token refresh: OIDC refresh_token rejected with invalid grant"); // The refresh was denied, signal to sign out the user. client.broadcast_unknown_token(soft_logout);