From 3b03b11d5860ba8dc472861a382b7edde5cceec2 Mon Sep 17 00:00:00 2001 From: Aleksei Voronov Date: Mon, 30 Oct 2023 21:38:15 +0100 Subject: [PATCH] Remove auth hack atrium_api 0.9.1 forwards auth stuff properly to clients, so we don't need this anymore --- src/services/bluesky/internals/xrpc.rs | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/services/bluesky/internals/xrpc.rs b/src/services/bluesky/internals/xrpc.rs index b3fa58a..efc0fed 100644 --- a/src/services/bluesky/internals/xrpc.rs +++ b/src/services/bluesky/internals/xrpc.rs @@ -1,7 +1,9 @@ +use std::error::Error; +use std::sync::{Arc, Mutex}; + use async_trait::async_trait; use atrium_xrpc::{client::reqwest::ReqwestClient, HttpClient, XrpcClient}; -use http::{Method, Request, Response}; -use std::sync::{Arc, Mutex}; +use http::{Request, Response}; use crate::services::bluesky::entities::Session; @@ -31,24 +33,7 @@ impl HttpClient for AuthenticateableXrpcClient { async fn send_http( &self, req: Request>, - ) -> Result>, Box> { - let (mut parts, body) = req.into_parts(); - - /* NOTE: This is a huge hack because auth is currently totally broken in atrium-api */ - let is_request_to_refresh_session = parts.method == Method::POST - && parts - .uri - .to_string() - .ends_with("com.atproto.server.refreshSession"); - if let Some(token) = self.auth(is_request_to_refresh_session) { - parts.headers.insert( - http::header::AUTHORIZATION, - format!("Bearer {}", token).parse()?, - ); - } - - let req = Request::from_parts(parts, body); - + ) -> Result>, Box> { self.inner.send_http(req).await } }