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:
@@ -1,4 +1,5 @@
|
||||
mod admin;
|
||||
mod auth;
|
||||
mod api;
|
||||
mod db;
|
||||
mod mtls;
|
||||
@@ -22,6 +23,13 @@ async fn main() -> Result<()> {
|
||||
|
||||
let data_dir = std::env::var("TESSERA_DATA_DIR").unwrap_or_else(|_| "./data".into());
|
||||
let listen = std::env::var("TESSERA_LISTEN").unwrap_or_else(|_| "127.0.0.1:8787".into());
|
||||
let addr: SocketAddr = listen.parse()?;
|
||||
let admin = admin::AdminGate::from_env()?;
|
||||
admin.validate_listener(addr)?;
|
||||
let wormhole = mtls::from_env()?;
|
||||
if let Some(config) = &wormhole {
|
||||
admin.validate_listener(config.listen)?;
|
||||
}
|
||||
let vault_pass = std::env::var("TESSERA_VAULT_PASSPHRASE")
|
||||
.ok()
|
||||
.filter(|value| !value.is_empty())
|
||||
@@ -37,6 +45,8 @@ async fn main() -> Result<()> {
|
||||
}
|
||||
|
||||
let mut state = HubState::bootstrap(&data_dir, &vault_pass).await?;
|
||||
anyhow::ensure!(state.sessions.enabled() || state.admin.token.is_some() || state.admin.local_development,
|
||||
"configure a named emergency operator and/or TESSERA_ADMIN_TOKEN; anonymous local access requires explicit TESSERA_LOCAL_DEVELOPMENT=true");
|
||||
|
||||
if std::env::var("TESSERA_SEED_DEMO")
|
||||
.map(|v| v == "1" || v == "true")
|
||||
@@ -69,7 +79,7 @@ async fn main() -> Result<()> {
|
||||
state.admin.log_policy();
|
||||
}
|
||||
|
||||
if let Some(wormhole) = mtls::from_env()? {
|
||||
if let Some(wormhole) = wormhole {
|
||||
state.wormhole_mtls = true;
|
||||
state.accept_plain_upload = false;
|
||||
let mut tls_state = state.clone();
|
||||
@@ -84,14 +94,7 @@ async fn main() -> Result<()> {
|
||||
tracing::info!("plain HTTP uploads are closed; wormhole clients use {listen_addr}");
|
||||
}
|
||||
|
||||
let admin_token_unset = state.admin.token.is_none();
|
||||
let app = api::router(state);
|
||||
let addr: SocketAddr = listen.parse()?;
|
||||
if addr.ip().is_unspecified() && admin_token_unset {
|
||||
tracing::warn!(
|
||||
"listening on {addr}; backup APIs reject non-loopback clients until TESSERA_ADMIN_TOKEN is set"
|
||||
);
|
||||
}
|
||||
tracing::info!("Tessera hub listening on {addr}");
|
||||
let listener = tokio::net::TcpListener::bind(addr).await?;
|
||||
axum::serve(
|
||||
|
||||
Reference in New Issue
Block a user