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