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:
@@ -7,9 +7,10 @@
|
||||
# `pass-broker get --item <title> --reason <why>`; scripts/deploy uses it.
|
||||
#
|
||||
# Telegram, not a desktop dialog: any process of darman's can fake Wayland
|
||||
# input and click its own approval. The bot must be dedicated to this: a bot
|
||||
# has one getUpdates consumer, so sharing it (e.g. with Hermes) would let the
|
||||
# other side see or swallow the approvals.
|
||||
# input and click its own approval. A bot has one getUpdates consumer, so
|
||||
# either this broker owns a dedicated bot (`telegram`) or it asks the shared
|
||||
# gateway on mars (`gateway`, pass-broker-gateway.nix), which owns the one
|
||||
# bot for every host.
|
||||
|
||||
let
|
||||
cfg = config.homelab.passBroker;
|
||||
@@ -24,11 +25,16 @@ let
|
||||
session_dir = "${stateDir}/session";
|
||||
pat_file = cfg.patFile;
|
||||
approval_timeout_secs = cfg.approvalTimeout;
|
||||
telegram = {
|
||||
api_base = cfg.telegram.apiBase;
|
||||
token_file = cfg.telegram.tokenFile;
|
||||
chat_id_file = cfg.telegram.chatIdFile;
|
||||
};
|
||||
approval =
|
||||
if cfg.gateway != null then {
|
||||
gateway = { inherit (cfg.gateway) url; token_file = cfg.gateway.tokenFile; };
|
||||
} else {
|
||||
telegram = {
|
||||
api_base = cfg.telegram.apiBase;
|
||||
token_file = cfg.telegram.tokenFile;
|
||||
chat_id_file = cfg.telegram.chatIdFile;
|
||||
};
|
||||
};
|
||||
rules = map (r: {
|
||||
inherit (r) vault item approval;
|
||||
grant_minutes = r.grantMinutes;
|
||||
@@ -69,19 +75,45 @@ in
|
||||
description = "Seconds to wait for a tap before refusing.";
|
||||
};
|
||||
|
||||
telegram = {
|
||||
apiBase = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "https://api.telegram.org";
|
||||
};
|
||||
tokenFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Bot token of a bot used for nothing else.";
|
||||
};
|
||||
chatIdFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Your Telegram user id; only its taps count.";
|
||||
};
|
||||
telegram = lib.mkOption {
|
||||
default = null;
|
||||
description = "Prompt via this broker's own bot. Exactly one of telegram/gateway.";
|
||||
type = lib.types.nullOr (lib.types.submodule {
|
||||
options = {
|
||||
apiBase = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "https://api.telegram.org";
|
||||
};
|
||||
tokenFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Bot token of a bot nothing else polls.";
|
||||
};
|
||||
chatIdFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Your Telegram user id; only its taps count.";
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
gateway = lib.mkOption {
|
||||
default = null;
|
||||
description = "Prompt via the shared gateway. Exactly one of telegram/gateway.";
|
||||
type = lib.types.nullOr (lib.types.submodule {
|
||||
options = {
|
||||
url = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "http://mars.orbit.sol:8097";
|
||||
};
|
||||
tokenFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = ''
|
||||
This host's gateway token; its sha256 goes in the gateway's
|
||||
homelab.passBrokerGateway.hosts.<host>.tokenSha256.
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
rules = lib.mkOption {
|
||||
@@ -116,6 +148,11 @@ in
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
assertions = [{
|
||||
assertion = (cfg.telegram == null) != (cfg.gateway == null);
|
||||
message = "homelab.passBroker: set exactly one of telegram or gateway.";
|
||||
}];
|
||||
|
||||
environment.systemPackages = [ pass-broker ];
|
||||
|
||||
users.users.pass-broker = {
|
||||
|
||||
Reference in New Issue
Block a user