cargo fmt

This commit is contained in:
Laurenz 2025-06-17 10:11:50 -07:00
parent ed715102c0
commit ba1a5f728c
Signed by: C0ffeeCode
SSH key fingerprint: SHA256:prvFOyBjButRypyXm7X8lbbCkly2Dq1PF7e/mrsPVjw
14 changed files with 40 additions and 35 deletions

View file

@ -40,7 +40,7 @@ pub async fn inspect_req(state: &DbPool, req: &Request<Body>) -> Result<AuthInfo
/// Inspects the request headers and extracts authentication information.
/// Returns an `AuthInfo` struct containing the token and roles if successful.
/// If the authorization header is missing or invalid, it returns a `StatusCode::UNAUTHORIZED`.
///
///
/// This function is intentionally separated so it can be used from
/// within the Axum extractor as well as in other functions.
pub async fn inspect_with_header(

View file

@ -1,6 +1,6 @@
// There are some placeholder functions, that will have to be implemented before the first release.
// There are some placeholder functions, that will have to be implemented before the first release.
// They are marked with `todo!()` to indicate that they need to be implemented.
// We want to keep these functions in the codebase.
// We want to keep these functions in the codebase.
// That is why we choose to suppress unused warnings for now.
// TODO
#![allow(unused)]
@ -209,7 +209,6 @@ async fn post_lookup(
// The following functions are placeholders for the various token-related operations.
//
async fn get_accessors() -> &'static str {
todo!("not implemented")
}

View file

@ -1,8 +1,8 @@
use axum::{
Json,
body::Body,
http::StatusCode,
response::{IntoResponse, Response},
Json,
};
use serde::Serialize;

View file

@ -1,11 +1,11 @@
pub mod kv;
use axum::{
Extension, Router,
body::Body,
extract::{Request, State},
http::{StatusCode, Uri},
response::{IntoResponse, Response},
Extension, Router,
};
use log::*;
use tower::Service;

View file

@ -1,15 +1,12 @@
mod structs;
mod data;
mod meta;
mod structs;
// #[cfg(test)]
// mod tests;
use crate::storage::DbPool;
use axum::{
Router,
routing::*,
};
use axum::{Router, routing::*};
pub fn kv_router(pool: DbPool) -> Router {
Router::new()

View file

@ -1,15 +1,19 @@
// There are some placeholder functions, that will have to be implemented before the first release.
// There are some placeholder functions, that will have to be implemented before the first release.
// They are marked with `todo!()` to indicate that they need to be implemented.
// We want to keep these functions in the codebase.
// We want to keep these functions in the codebase.
// That is why we choose to suppress unused warnings for now.
// TODO
#![allow(unused)]
use super::structs::KvV2WriteRequest;
use crate::{
common::HttpError, engines::{
kv::structs::{KvSecretData, KvSecretRes, KvV2WriteResponse, Wrapper}, EnginePath
}, storage::sealing::Secret, DbPool
DbPool,
common::HttpError,
engines::{
EnginePath,
kv::structs::{KvSecretData, KvSecretRes, KvV2WriteResponse, Wrapper},
},
storage::sealing::Secret,
};
use axum::{
Extension, Json,
@ -128,7 +132,10 @@ pub async fn post_data(
let content = serde_json::to_string(&secret.data).unwrap();
let Secret { nonce, protected_data } = Secret::encrypt(&content).await.unwrap();
let Secret {
nonce,
protected_data,
} = Secret::encrypt(&content).await.unwrap();
let nonce = nonce.as_slice();
let mut tx = pool.begin().await.unwrap();
@ -243,4 +250,4 @@ pub async fn patch_data(
Json(secret): Json<KvV2WriteRequest>,
) -> &'static str {
todo!("not implemented")
}
}

View file

@ -1,6 +1,6 @@
// There are some placeholder functions, that will have to be implemented before the first release.
// There are some placeholder functions, that will have to be implemented before the first release.
// They are marked with `todo!()` to indicate that they need to be implemented.
// We want to keep these functions in the codebase.
// We want to keep these functions in the codebase.
// That is why we choose to suppress unused warnings for now.
// TODO
#![allow(unused)]

View file

@ -1,6 +1,6 @@
// There are some placeholder functions, that will have to be implemented before the first release.
// There are some placeholder functions, that will have to be implemented before the first release.
// They are marked with `todo!()` to indicate that they need to be implemented.
// We want to keep these functions in the codebase.
// We want to keep these functions in the codebase.
// That is why we choose to suppress unused warnings for now.
#![allow(unused)]

View file

@ -1,19 +1,19 @@
#![forbid(unsafe_code)]
// // There are some placeholder functions, that will have to be implemented before the first release.
// // There are some placeholder functions, that will have to be implemented before the first release.
// // They are marked with `todo!()` to indicate that they need to be implemented.
// // We want to keep these functions in the codebase.
// // We want to keep these functions in the codebase.
// // That is why we choose to suppress unused warnings for now.
// #![allow(unused)]
use crate::common::HttpError;
use axum::{
Router,
extract::Request,
http::StatusCode,
middleware::{self, Next},
response::{IntoResponse, Response},
routing::get,
Router,
};
use log::*;
use std::{env, net::SocketAddr, str::FromStr};
@ -75,7 +75,7 @@ async fn set_default_content_type_json(
) -> Result<impl IntoResponse, Response> {
if req.headers().get("content-type").is_none() {
let headers = req.headers_mut();
headers.insert("content-type", "application/json".parse().unwrap());
}
@ -109,7 +109,7 @@ async fn shutdown_signal(pool: DbPool) {
}
/// Fallback route for unknown routes
///
///
/// Note: `/v1/*` is handled by [`engines::secrets_router`]
async fn fallback_route_unknown(req: Request) -> Response {
log::error!(

View file

@ -3,14 +3,14 @@ pub mod sealing;
use std::{fs::File, path::Path};
use log::*;
use sqlx::{sqlite::SqlitePoolOptions, Pool, Sqlite};
use sqlx::{Pool, Sqlite, sqlite::SqlitePoolOptions};
pub(crate) type DbType = Sqlite;
pub(crate) type DbPool = Pool<DbType>;
/// Creates a SQLx SQLite database pool.
/// If nonexistent, it creates a new SQLite file.
///
///
/// Note: rvault uses compile-time queries.
/// Hence, during development a migrated SQLite file is required.
/// Use `cargo sqlx database reset` if required.

View file

@ -15,7 +15,7 @@ use zeroize::ZeroizeOnDrop;
use crate::DbPool;
use super::{write_new_root_key, Sealing, UnsealResult};
use super::{Sealing, UnsealResult, write_new_root_key};
type P256Share = DefaultShare<IdentifierPrimeField<Scalar>, IdentifierPrimeField<Scalar>>;
@ -38,7 +38,7 @@ pub struct ShamirBucket {
}
impl Sealing for ShamirBucket {
fn new(protected_rk: Vec<u8>, nonce: Vec<u8>) -> Self {
fn new(protected_rk: Vec<u8>, nonce: Vec<u8>) -> Self {
Self {
portions: Vec::with_capacity(2),
protected_rk,
@ -46,7 +46,7 @@ impl Sealing for ShamirBucket {
}
}
async fn unseal(&mut self, key: String) -> UnsealResult {
async fn unseal(&mut self, key: String) -> UnsealResult {
let key = match BASE64_STANDARD.decode(key) {
Ok(v) => v,
Err(e) => {

View file

@ -6,7 +6,7 @@ use base64::{Engine, prelude::BASE64_STANDARD};
use crate::DbPool;
use super::{write_new_root_key, Sealing, UnsealResult};
use super::{Sealing, UnsealResult, write_new_root_key};
/// Pair of protected root key and nonce
#[derive(PartialEq)]

View file

@ -5,8 +5,8 @@ use crate::DbPool;
pub fn root_generation() -> Router<DbPool> {
Router::new()
// .route("/generate-root", get(get_root_generation_attempt))
.route("/generate-root", post(generate_new_root))
// .route("/generate-root", delete(cancel_generate_root))
.route("/generate-root", post(generate_new_root))
}
async fn generate_new_root() {

View file

@ -1,5 +1,7 @@
use axum::{
extract::State, routing::{get, post, put}, Json, Router
Json, Router,
extract::State,
routing::{get, post, put},
};
use log::warn;
use serde::Deserialize;