diff --git a/src/auth/auth_extractor.rs b/src/auth/auth_extractor.rs index df62c2d..40930db 100644 --- a/src/auth/auth_extractor.rs +++ b/src/auth/auth_extractor.rs @@ -23,7 +23,7 @@ impl FromRequestParts for AuthInfo { ) -> Result { let header = &parts.headers; - inspect_with_header(state, &header).await + inspect_with_header(state, header).await } } diff --git a/src/auth/token.rs b/src/auth/token.rs index 40db8ce..6fb4a67 100644 --- a/src/auth/token.rs +++ b/src/auth/token.rs @@ -1,14 +1,13 @@ use crate::storage::DbPool; -use axum::extract::{Path, Query, State}; +use axum::extract::State; use axum::http::StatusCode; -use axum::response::{IntoResponse, NoContent, Response}; +use axum::response::{IntoResponse, Response}; use axum::routing::post; use axum::{Json, Router}; use log::error; use rand::{Rng, distributions::Alphanumeric}; use serde::{Deserialize, Serialize}; use sqlx::Error; -use std::ops::Index; use uuid::Uuid; #[derive(Debug, Serialize)] @@ -83,8 +82,8 @@ pub async fn create_root_token_if_none_exist(pool: &DbPool) -> bool { if result.is_err() { let error = result.err().unwrap(); // Log the error and panic - error!("create_root_token failed: {:?}", error); - panic!("create_root_token failed: {:?}", error); + error!("create_root_token failed: {error:?}"); + panic!("create_root_token failed: {error:?}"); } // If successful, print the root token. This will only happen once. println!("\n\nYour root token is: {}", result.unwrap()); @@ -190,7 +189,7 @@ async fn post_lookup( } // If the token is not found, return a 404 Not Found error Err(e) => { - error!("Failed to retrieve token: {:?}", e); + error!("Failed to retrieve token: {e:?}"); let err = ErrorResponse { error: "Failed to retrieve token".to_string(), }; @@ -203,40 +202,79 @@ async fn post_lookup( // The following functions are placeholders for the various token-related operations. // -async fn get_accessors() {} -async fn post_create() {} +async fn get_accessors() -> &'static str { + todo!("not implemented") +} -async fn post_create_orphan() {} +async fn post_create() -> &'static str { + todo!("not implemented") +} -async fn post_create_role() {} +async fn post_create_orphan() -> &'static str { + todo!("not implemented") +} -async fn get_lookup() {} +async fn post_create_role() -> &'static str { + todo!("not implemented") +} -async fn get_lookup_self() {} +async fn get_lookup() -> &'static str { + todo!("not implemented") +} -async fn post_lookup_self() {} +async fn get_lookup_self() -> &'static str { + todo!("not implemented") +} -async fn post_renew() {} +async fn post_lookup_self() -> &'static str { + todo!("not implemented") +} -async fn post_renew_accessor() {} +async fn post_renew() -> &'static str { + todo!("not implemented") +} -async fn post_renew_self() {} +async fn post_renew_accessor() -> &'static str { + todo!("not implemented") +} -async fn post_revoke() {} +async fn post_renew_self() -> &'static str { + todo!("not implemented") +} -async fn post_revoke_accessor() {} +async fn post_revoke() -> &'static str { + todo!("not implemented") +} -async fn post_revoke_orphan() {} +async fn post_revoke_accessor() -> &'static str { + todo!("not implemented") +} -async fn post_revoke_self() {} +async fn post_revoke_orphan() -> &'static str { + todo!("not implemented") +} -async fn get_roles() {} +async fn post_revoke_self() -> &'static str { + todo!("not implemented") +} -async fn get_role_by_name() {} +async fn get_roles() -> &'static str { + todo!("not implemented") +} -async fn post_role_by_name() {} +async fn get_role_by_name() -> &'static str { + todo!("not implemented") +} -async fn delete_role_by_name() {} +async fn post_role_by_name() -> &'static str { + todo!("not implemented") +} -async fn post_tidy() {} +async fn delete_role_by_name() -> &'static str { + todo!("not implemented") +} + +async fn post_tidy() -> &'static str { + todo!("not implemented") +} diff --git a/src/common.rs b/src/common.rs index 928ad2c..13a1b1a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -13,12 +13,12 @@ pub struct HttpError { } impl HttpError { - pub fn new(status_code: StatusCode, errors: Vec) -> Response { + pub fn simple_with_status(status_code: StatusCode, errors: Vec) -> Response { (status_code, Json(HttpError { errors })).into_response() } pub fn simple(status_code: StatusCode, error: impl ToString) -> Response { - HttpError::new(status_code, vec![error.to_string(); 1]) + HttpError::simple_with_status(status_code, vec![error.to_string(); 1]) } } diff --git a/src/engines.rs b/src/engines.rs index f767c7a..fcea8ba 100644 --- a/src/engines.rs +++ b/src/engines.rs @@ -42,7 +42,7 @@ async fn engine_handler( req: Request, ) -> Response { if let Some((mount_path, engine_type)) = map_mount_points(req.uri(), &engines.pool).await { - info!("Found mount point {} of type {}", mount_path, engine_type); + info!("Found mount point {mount_path} of type {engine_type}"); // Match the engine type to the appropriate router match engine_type.as_str() { "kv_v2" => call_router(engines.kv_v2, mount_path, req).await, @@ -72,7 +72,7 @@ async fn call_router(engine: Router, mount_path: String, mut req: Request) -> Re /// Occurs when the mount path is found in the database /// but the registered is unknown fn unknown_engine(engine_type: String) -> impl IntoResponse { - error!("Engine type {} not implemented", engine_type); + error!("Engine type {engine_type} not implemented"); HttpError::simple( StatusCode::INTERNAL_SERVER_ERROR, format!("Engine type {engine_type} not implemented"), diff --git a/src/engines/kv/data.rs b/src/engines/kv/data.rs index 0e1c0c5..aca815e 100644 --- a/src/engines/kv/data.rs +++ b/src/engines/kv/data.rs @@ -234,7 +234,6 @@ pub async fn patch_data( Path(kv_path): Path, Extension(EnginePath(engine_path)): Extension, Json(secret): Json, -) -> Result { - // TODO: implement only application/merge-patch+json - todo!("Not implemented") -} +) -> &'static str { + todo!("not implemented") +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 3a23e6f..c27444d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,11 @@ #![forbid(unsafe_code)] -use crate::auth::auth_extractor::AuthInfo; +// 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. +// That is why we choose to suppress unused warnings for now. +#![allow(unused)] + use crate::common::HttpError; use axum::{ extract::Request, diff --git a/src/storage/sealing.rs b/src/storage/sealing.rs index 8dc9580..c0f72fb 100644 --- a/src/storage/sealing.rs +++ b/src/storage/sealing.rs @@ -321,11 +321,11 @@ pub async fn init_default(pool: &DbPool) { #[cfg(feature = "shamir")] { - shamir::init_shamir(&pool, 2, 5).await + shamir::init_shamir(pool, 2, 5).await } }; - let success = prepare_unseal(&pool).await; + let success = prepare_unseal(pool).await; warn!("New sealing password generated: {user_key:?}"); assert!( success, diff --git a/src/sys/sealing.rs b/src/sys/sealing.rs index e634d11..386b811 100644 --- a/src/sys/sealing.rs +++ b/src/sys/sealing.rs @@ -47,4 +47,6 @@ async fn unseal_post(State(pool): State, Json(req): Json) Ok(()) } -async fn seal_status_get(State(pool): State) {} +async fn seal_status_get(State(pool): State) -> &'static str { + todo!("not implemented") +}