From 56dfb7ec77a5aec6cb37ebcdc11c31d5f4190f71 Mon Sep 17 00:00:00 2001 From: hectorsector Date: Mon, 30 Mar 2026 12:22:51 -0400 Subject: [PATCH] begin callback handler, update build sequence --- src/auth/oauth.rs | 24 ++++++++++++++++++++++++ src/main.rs | 1 + 2 files changed, 25 insertions(+) diff --git a/src/auth/oauth.rs b/src/auth/oauth.rs index 53685a6..5710016 100644 --- a/src/auth/oauth.rs +++ b/src/auth/oauth.rs @@ -108,6 +108,12 @@ pub struct LoginParams { handle: String, } +#[derive(Deserialize)] +pub struct CallbackParams { + code: String, + state: String, +} + #[axum::debug_handler] pub async fn login_handler( cookies: Cookies, @@ -160,3 +166,21 @@ pub async fn login_handler( Ok(Redirect::temporary(&url)) } + +#[axum::debug_handler] +pub async fn callback_handler( + cookies: Cookies, + Query(params): Query, +) -> Result { + let cookie = cookies + .get("pending_authorization") + .ok_or(anyhow::anyhow!("missing cookie"))?; + + let cookie_string = cookie.value(); + + let cookie_bytes = BASE64_URL_SAFE_NO_PAD.decode(cookie_string)?; + + let pending: PendingAuth = serde_json::from_slice(&cookie_bytes)?; + + return Ok(Redirect::temporary("")); +} diff --git a/src/main.rs b/src/main.rs index 276727a..279909f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ async fn main() { let app = Router::new() .route("/", get(|| async { "Hello from rusty-cairns" })) .route("/auth/login", get(login_handler)) + .route("auth/callback", get(callback_handler)) .layer(CookieManagerLayer::new()); //query params handled by axum let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap(); -- 2.51.2