From 920e4d11c1498b357997d2150a59cad27bb5fe3b Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Sun, 28 Jun 2026 21:20:56 +0530 Subject: [PATCH] docs: Added credits --- README.md | 5 +++++ src/handlers.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/README.md b/README.md index 6e98990..73a34e0 100644 --- a/README.md +++ b/README.md @@ -162,3 +162,8 @@ sequenceDiagram Note over C: Decrypts payload using local Private Key ``` + +## Credits + +* [David Wong](https://cryptologie.net/posts/eddsa-ed25519-ed25519-ietf-ed25519ph-ed25519ctx-hasheddsa-pureeddsa-wtf/) for his brief intro to EdDSA and Ed25519 on his blog post. + diff --git a/src/handlers.rs b/src/handlers.rs index 2f9b4de..49d62f0 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -132,6 +132,39 @@ pub async fn approve( Ok(Json("Approved!").into_response()) } +#[derive(Serialize)] +pub struct PendingDeviceRes { + pub hostname: String, + pub os: String, + pub public_key: String, +} + +pub async fn get_pending_device( + State(state): State, + axum::extract::Path(user_code): axum::extract::Path, +) -> Result, StatusCode> { + let record = sqlx::query_as::<_, (String, String, String)>( + "SELECT hostname, os, public_key FROM devices WHERE user_code = ? AND approved_at IS NULL", + ) + .bind(&user_code) + .fetch_optional(&state.pool) + .await + .map_err(|err| { + tracing::error!("Database error fetching pending device: {:?}", err); + StatusCode::INTERNAL_SERVER_ERROR + })?; + + if let Some((hostname, os, public_key)) = record { + Ok(Json(PendingDeviceRes { + hostname, + os, + public_key, + })) + } else { + Err(StatusCode::NOT_FOUND) + } +} + #[derive(Deserialize)] pub struct PollReq { pub user_code: String,