Skip to content

Commit

Permalink
refactor(oidc): Only revoke one token for logout
Browse files Browse the repository at this point in the history
The server is supposed to revoke any token associated with the token that we revoke.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
  • Loading branch information
zecakeh authored and poljar committed Feb 24, 2025
1 parent d4b92de commit 55f5148
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
9 changes: 3 additions & 6 deletions crates/matrix-sdk/src/authentication/oidc/cross_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,11 @@ mod tests {

oidc.logout().await?;

// Both the access token and the refresh tokens have been invalidated.
// The access token has been invalidated.
{
let revoked = backend.revoked_tokens.lock().unwrap();
assert_eq!(revoked.len(), 2);
assert_eq!(
*revoked,
vec![tokens.access_token.clone(), tokens.refresh_token.clone().unwrap(),]
);
assert_eq!(revoked.len(), 1);
assert_eq!(*revoked, &[tokens.access_token]);
}

{
Expand Down
16 changes: 2 additions & 14 deletions crates/matrix-sdk/src/authentication/oidc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,28 +1476,16 @@ impl Oidc {

let tokens = self.session_tokens().ok_or(OidcError::NotAuthenticated)?;

// Revoke the access token.
// Revoke the access token, it should revoke both tokens.
self.backend
.revoke_token(
client_credentials.clone(),
client_credentials,
revocation_endpoint,
tokens.access_token,
Some(OAuthTokenTypeHint::AccessToken),
)
.await?;

// Revoke the refresh token, if any.
if let Some(refresh_token) = tokens.refresh_token {
self.backend
.revoke_token(
client_credentials.clone(),
revocation_endpoint,
refresh_token,
Some(OAuthTokenTypeHint::RefreshToken),
)
.await?;
}

if let Some(manager) = self.ctx().cross_process_token_refresh_manager.get() {
manager.on_logout().await?;
}
Expand Down

0 comments on commit 55f5148

Please sign in to comment.