feat: require authentication and own uploads per Outpost (auth M0)

- auth is mandatory by default, including loopback and local proxies; startup refuses a hub with no credentials; TESSERA_LOCAL_DEVELOPMENT is explicit and loopback-only
- legacy uploads are bound to an owning Outpost (PUT /api/v1/orbits/:id/outpost); unowned orbits and sessions fail closed
- typed Principal and payload-free audit_events table
- endpoint authorization contract with tests comparing it to the router
- A00 compatibility spike (tests/auth-compat) and library research
- archive the superseded A00-A25 plan

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 12:59:08 +07:00
parent f6a41ee702
commit a9ebded5ba
22 changed files with 5355 additions and 35 deletions

View File

@@ -0,0 +1,81 @@
//! Server-derived identities and payload-free audit records.
use uuid::Uuid;
#[derive(Clone, Debug)]
pub enum Principal {
Emergency(String),
Service(&'static str),
Outpost(Uuid),
Anonymous,
LocalDevelopment,
}
impl Principal {
pub fn fields(&self) -> (String, &'static str, &'static str) {
match self {
Self::Emergency(name) => (format!("emergency:{name}"), "user", "password"),
Self::Service(id) => (id.to_string(), "service", "api_token"),
Self::Outpost(id) => (id.to_string(), "outpost", "outpost_token"),
Self::Anonymous => ("anonymous".into(), "anonymous", "none"),
Self::LocalDevelopment => ("local-development".into(), "service", "development"),
}
}
}
pub enum AuditAction {
Authentication,
Authorization,
Login,
Logout,
OutpostBind,
}
impl AuditAction {
pub fn as_str(&self) -> &'static str {
match self {
Self::Authentication => "authentication.check",
Self::Authorization => "authorization.check",
Self::Login => "auth.login",
Self::Logout => "auth.logout",
Self::OutpostBind => "orbit.outpost_bind",
}
}
}
pub enum AuditOutcome {
Allowed,
Denied,
Succeeded,
Failed,
}
impl AuditOutcome {
pub fn as_str(&self) -> &'static str {
match self {
Self::Allowed => "allowed",
Self::Denied => "denied",
Self::Succeeded => "succeeded",
Self::Failed => "failed",
}
}
}
pub enum AuditResource {
Api,
Session,
Orbit(Uuid),
Outpost(Uuid),
UploadSession(Uuid),
}
impl AuditResource {
pub fn fields(&self) -> (&'static str, Option<String>) {
match self {
Self::Api => ("api", None),
Self::Session => ("session", None),
Self::Orbit(id) => ("orbit", Some(id.to_string())),
Self::Outpost(id) => ("outpost", Some(id.to_string())),
Self::UploadSession(id) => ("upload_session", Some(id.to_string())),
}
}
}