feat(mars): pass-broker approval gateway for every host

A Telegram bot has a single getUpdates consumer, so a broker per host
would split approval taps between them. mars now runs the gateway: the
bot's only poller, relaying prompts and taps for terra's and titan's
brokers over the tailnet (:8097) without ever seeing an item. Each broker
authenticates with its own pass_broker_gateway_token; mars holds only the
sha256, and the prompt is labelled with the host that token belongs to.

The bot token and chat id move to mars and are dropped from the other
hosts' sops files (terra.yaml also loses its leftover LibreChat keys and
gains protonvpn_wg_private_key, which a later commit uses). Covered by
checks.pass-broker-gateway (two nodes: labels, cancel, expiry, per-host
token isolation, gateway down); the fakes are shared with checks.pass-broker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 11:34:19 +02:00
co-authored by Claude Opus 5.5
parent 760e353335
commit e95726d69c
24 changed files with 1164 additions and 250 deletions
+39 -4
View File
@@ -13,11 +13,19 @@ pub struct Config {
pub session_dir: PathBuf,
pub pat_file: PathBuf,
pub approval_timeout_secs: u64,
pub telegram: TelegramConfig,
pub approval: ApprovalConfig,
/// First match wins; no match means deny.
pub rules: Vec<Rule>,
}
/// Who shows the prompt: this broker's own bot, or the shared gateway.
#[derive(Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ApprovalConfig {
Telegram(TelegramConfig),
Gateway(GatewayClientConfig),
}
#[derive(Deserialize)]
pub struct TelegramConfig {
pub api_base: String,
@@ -25,6 +33,35 @@ pub struct TelegramConfig {
pub chat_id_file: PathBuf,
}
#[derive(Deserialize)]
pub struct GatewayClientConfig {
pub url: String,
pub token_file: PathBuf,
}
/// Written by services/identity/pass-broker-gateway.nix; path in
/// $PASS_BROKER_GATEWAY_CONFIG.
#[derive(Deserialize)]
pub struct GatewayConfig {
pub listen: String,
pub telegram: TelegramConfig,
/// Hashes only: the gateway host never holds a broker's token.
pub hosts: Vec<GatewayHost>,
pub max_timeout_secs: u64,
}
#[derive(Deserialize)]
pub struct GatewayHost {
pub name: String,
pub token_sha256: String,
}
pub fn load<T: serde::de::DeserializeOwned>(var: &str) -> Result<T> {
let path = std::env::var(var).with_context(|| format!("{var} unset"))?;
let text = std::fs::read_to_string(&path).with_context(|| format!("reading {path}"))?;
serde_json::from_str(&text).with_context(|| format!("parsing {path}"))
}
#[derive(Deserialize)]
pub struct Rule {
pub vault: Option<String>,
@@ -45,9 +82,7 @@ pub enum Approval {
impl Config {
pub fn load() -> Result<Self> {
let path = std::env::var("PASS_BROKER_CONFIG").context("PASS_BROKER_CONFIG unset")?;
let text = std::fs::read_to_string(&path).with_context(|| format!("reading {path}"))?;
serde_json::from_str(&text).with_context(|| format!("parsing {path}"))
load("PASS_BROKER_CONFIG")
}
pub fn rule_for(&self, vault: &str, item: &str) -> Option<&Rule> {