From 0d62c9de7ce96d90356210084dc36449df59af0d Mon Sep 17 00:00:00 2001 From: Matthias Ahouansou Date: Tue, 2 Apr 2024 17:19:59 +0100 Subject: [PATCH] fix: ignore access tokens where they are not needed --- src/api/ruma_wrapper/axum.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/api/ruma_wrapper/axum.rs b/src/api/ruma_wrapper/axum.rs index 43e73c66..895b601d 100644 --- a/src/api/ruma_wrapper/axum.rs +++ b/src/api/ruma_wrapper/axum.rs @@ -110,7 +110,8 @@ where ( AuthScheme::AccessToken | AuthScheme::AppserviceToken - | AuthScheme::AccessTokenOptional, + | AuthScheme::AccessTokenOptional + | AuthScheme::None, Token::Appservice(info), ) => { let user_id = query_params @@ -144,7 +145,7 @@ where )); } ( - AuthScheme::AccessToken | AuthScheme::AccessTokenOptional, + AuthScheme::AccessToken | AuthScheme::AccessTokenOptional | AuthScheme::None, Token::User((user_id, device_id)), ) => (Some(user_id), Some(device_id), None, false), (AuthScheme::ServerSignatures, Token::None) => { @@ -259,13 +260,10 @@ where | AuthScheme::AccessTokenOptional, Token::None, ) => (None, None, None, false), - ( - AuthScheme::ServerSignatures | AuthScheme::None, - Token::Appservice(_) | Token::User(_), - ) => { + (AuthScheme::ServerSignatures, Token::Appservice(_) | Token::User(_)) => { return Err(Error::BadRequest( ErrorKind::Unauthorized, - "Access tokens should not be used on this endpoint.", + "Only server signatures should be used on this endpoint.", )); } (AuthScheme::AppserviceToken, Token::User(_)) => {