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
+8 -8
View File
@@ -1,7 +1,8 @@
use crate::config::{Approval, Config};
use crate::pass::Pass;
use crate::proto::{Reply, Request};
use crate::telegram::{Telegram, Verdict};
use crate::approver::Approver;
use crate::telegram::Verdict;
use anyhow::{bail, Context, Result};
use std::collections::HashMap;
use std::future::Future;
@@ -18,10 +19,10 @@ struct State {
cfg: Config,
uids: Vec<u32>,
pass: Pass,
tg: Telegram,
approver: Approver,
/// "vault\0item" -> when the last approval stops covering it.
grants: Mutex<HashMap<String, Instant>>,
/// One prompt at a time; Telegram::ask polls getUpdates itself.
/// One prompt per host at a time; direct mode polls getUpdates in ask.
asking: Mutex<()>,
}
@@ -30,7 +31,7 @@ pub async fn run() -> Result<()> {
let state = Arc::new(State {
uids: cfg.allowed_uids()?,
pass: Pass::new(&cfg),
tg: Telegram::new(&cfg.telegram)?,
approver: Approver::new(&cfg.approval, &cfg.host)?,
grants: Mutex::new(HashMap::new()),
asking: Mutex::new(()),
cfg,
@@ -161,9 +162,8 @@ async fn decide(
0 => "Approves this request only.".to_string(),
n => format!("Approving covers further requests for {n} min."),
};
let text = format!(
"🔑 {host}: {vault} / {item} ({field})\nReason: {reason}\nBy: {by}\nCommand: {command}\nChain: {chain}\n{grant}",
host = state.cfg.host,
let body = format!(
"{vault} / {item} ({field})\nReason: {reason}\nBy: {by}\nCommand: {command}\nChain: {chain}\n{grant}",
item = req.item,
field = req.field,
reason = req.reason,
@@ -172,7 +172,7 @@ async fn decide(
chain = who.chain,
);
let timeout = Duration::from_secs(state.cfg.approval_timeout_secs);
match state.tg.ask(&text, timeout, gone).await? {
match state.approver.ask(&body, timeout, gone).await? {
Verdict::Approved => {
if rule.grant_minutes > 0 {
let until = Instant::now() + Duration::from_secs(rule.grant_minutes * 60);