P0: config, DTOs, source traits, fakes, error, state and module stubs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ariandClaude Sonnet 5.5 committed 2026-10-15 17:23:17 -04:00
1 parent aa9b0da962
commit 1802f97d94
22 files changed
+1736

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
//! Bearer-token auth (WS-D owns `src/auth/`).
//!
//! STUB: signature is final. Failures respond `401` with
//! `WWW-Authenticate: Bearer` and the standard JSON error body (DEC-4), for
//! both REST and `/mcp`. Apply the layer to the protected router only.
pub mod tokens;
use std::convert::Infallible;
use axum::extract::{Request, State};
use axum::middleware::{self, Next};
use axum::response::Response;
use axum::routing::Route;
use tower::{Layer, Service};
use crate::state::AppState;
/// Verify `Authorization: Bearer <token>` (sha256 + indexed lookup).
/// When `config.auth.enabled` is false this passes requests through.
async fn require_token(State(_state): State<AppState>, _req: Request, _next: Next) -> Response {
todo!("WS-D D5")
}
/// Layer for `Router::layer` on the protected router (`/api/v1`, `/mcp`).
pub fn layer(
state: AppState,
) -> impl Layer<
Route,
Service = impl Service<Request, Response = Response, Error = Infallible, Future: Send>
+ Clone
+ Send
+ Sync
+ 'static,
> + Clone
+ Send
+ Sync
+ 'static {
middleware::from_fn_with_state(state, require_token)
}
+28
View File
@@ -0,0 +1,28 @@
//! Token CRUD and the `slinuxm token` CLI (WS-D owns this file).
//!
//! STUB: `TokenCmd` and `run` signatures are final. Tokens have the prefix
//! `slinuxm_`, 32 random bytes, only the sha256 hash is stored, and the
//! plaintext is printed once on create.
use anyhow::Result;
use clap::Subcommand;
use crate::config::Config;
#[derive(Debug, Clone, Subcommand)]
pub enum TokenCmd {
/// Create a token and print it once.
Create {
/// Unique token name.
name: String,
},
/// List tokens (never prints secrets).
List,
/// Revoke a token by name.
Revoke { name: String },
}
/// Execute a token subcommand against the DB at `config.auth.db_path`.
pub async fn run(_cmd: TokenCmd, _config: &Config) -> Result<()> {
todo!("WS-D D3/D4")
}