diff --git a/apps/labrinth/src/auth/validate.rs b/apps/labrinth/src/auth/validate.rs index e69d19431..8b8769c9d 100644 --- a/apps/labrinth/src/auth/validate.rs +++ b/apps/labrinth/src/auth/validate.rs @@ -154,10 +154,15 @@ pub fn extract_authorization_header( ) -> Result<&str, AuthenticationError> { let headers = req.headers(); let token_val: Option<&HeaderValue> = headers.get(AUTHORIZATION); - token_val + let token_val = token_val .ok_or_else(|| AuthenticationError::InvalidAuthMethod)? .to_str() - .map_err(|_| AuthenticationError::InvalidCredentials) + .map_err(|_| AuthenticationError::InvalidCredentials)?; + Ok(if let Some(token) = token_val.strip_prefix("Bearer ") { + token + } else { + token_val + }) } pub async fn check_is_moderator_from_headers<'a, 'b, E>(