miroir/crates/miroir-proxy/src/auth.rs
jedarden 9b5cf0ddcd P0.3: Scaffold miroir-proxy crate
- Added Cargo.toml with axum, tokio, reqwest, serde, tracing, prometheus
- Created main.rs: binds :7700 (main API) and :9090 (metrics)
- Route handler stubs: documents, search, indexes, settings, tasks, health, admin
- auth.rs: bearer-token dispatch skeleton (client/admin token kinds)
- middleware.rs: tracing/logging + Prometheus middleware stubs
- Fixed miroir-core/migration.rs: Display impls, Instant serialization, borrow fixes

Acceptance:
- Binary builds successfully
- Health endpoint returns {"status":"available"}
- Stripped binary: 2.3 MB (< 20 MB target)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 20:57:58 -04:00

31 lines
725 B
Rust

//! Bearer-token dispatch per plan §5
//!
//! Phase 2 will implement the full token-based routing logic.
//! This module is currently a stub.
use http::header::HeaderMap;
#[derive(Debug, Clone, PartialEq)]
#[allow(dead_code)]
pub enum TokenKind {
Client,
Admin,
}
#[derive(Debug)]
#[allow(dead_code)]
pub struct AuthContext {
pub token_kind: TokenKind,
pub token: Option<String>,
}
#[allow(dead_code)]
pub fn classify_token(headers: &HeaderMap) -> Option<AuthContext> {
let auth_header = headers.get("authorization")?.to_str().ok()?;
let token = auth_header.strip_prefix("Bearer ")?;
Some(AuthContext {
token_kind: TokenKind::Client,
token: Some(token.to_string()),
})
}