Microservice to bring 2FA to self hosted PDSes

little more clean up

authored by baileytownsend.dev and committed by Tangled d2bf726f 01148f8a

Changed files
+6 -6
src
+4 -2
src/main.rs
··· 19 19 use std::time::Duration; 20 20 use std::{env, net::SocketAddr}; 21 21 use tower_governor::GovernorLayer; 22 - use tower_governor::governor::{GovernorConfig, GovernorConfigBuilder}; 22 + use tower_governor::governor::GovernorConfigBuilder; 23 23 use tower_http::compression::CompressionLayer; 24 24 use tower_http::cors::{Any, CorsLayer}; 25 25 use tracing::log; ··· 97 97 "Error loading pds.env file (ignore if you loaded your variables in the environment somehow else): {e}" 98 98 ); 99 99 } 100 - let pds_root = env::var("PDS_DATA_DIRECTORY")?; 100 + 101 + let pds_root = 102 + env::var("PDS_DATA_DIRECTORY").expect("PDS_DATA_DIRECTORY is not set in your pds.env file"); 101 103 let account_db_url = format!("{pds_root}/account.sqlite"); 102 104 103 105 let account_options = SqliteConnectOptions::new()
-2
src/middleware.rs
··· 1 1 use crate::helpers::json_error_response; 2 2 use axum::extract::Request; 3 - use axum::http::header::AUTHORIZATION; 4 3 use axum::http::{HeaderMap, StatusCode}; 5 4 use axum::middleware::Next; 6 5 use axum::response::IntoResponse; ··· 73 72 .expect("Error creating an error response"); 74 73 } 75 74 let token = token.expect("Already checked for error,"); 76 - // Not going to worry about expiration since it still goes to the PDS 77 75 req.extensions_mut() 78 76 .insert(Did(Some(token.claims().custom.sub.clone()))); 79 77 }
+2 -2
src/xrpc/com_atproto_server.rs
··· 10 10 use axum::{Extension, Json, debug_handler, extract, extract::Request}; 11 11 use serde::{Deserialize, Serialize}; 12 12 use serde_json; 13 - use sqlx::Error; 14 - use sqlx::sqlite::SqliteQueryResult; 15 13 use tracing::log; 16 14 17 15 #[derive(Serialize, Deserialize, Debug, Clone)] ··· 289 287 State(state): State<AppState>, 290 288 mut req: Request, 291 289 ) -> Result<Response<Body>, StatusCode> { 290 + //TODO if I add the block of only accounts authenticated just take the body as json here and grab the lxm token. No middle ware is needed 291 + 292 292 let uri = format!( 293 293 "{}{}", 294 294 state.pds_base_url, "/xrpc/com.atproto.server.createAccount"