docs: Added credits
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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<AppState>,
|
||||
axum::extract::Path(user_code): axum::extract::Path<String>,
|
||||
) -> Result<Json<PendingDeviceRes>, 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,
|
||||
|
||||
Reference in New Issue
Block a user