Watch
0
0
Fork
You've already forked hyperhive
0

default the host's swarmctl to the gateway; login takes a callback port

This commit is contained in:
atlas 2026-11-22 15:00:54 +01:00
commit 58236e1b7f
4 changed files with 183 additions and 67 deletions

View file

@ -53,7 +53,8 @@ the `shamir` seal, the restart after the granter, and the browser login.
Run `swarmctl setup status` at any point to see how far you have got. It
changes nothing, and it works from a script: it exits 0 when every step it can
see has finished.
see has finished. The agent steps (9 and 10) read the controller, so they show `unknown` until
`swarmctl login` has run.
```console
# swarmctl setup status
@ -172,12 +173,27 @@ name resolves on the box itself through `/etc/hosts`; from anywhere else it
needs a real DNS record. → [`2-handbook/swarm/ui.md`](../2-handbook/swarm/ui.md)
Signing in to the forge once through SSO creates your forge account under the
same username. Then, _on the swarm-controller's host_:
same username. Then, _on the swarm-controller's host_, log `swarmctl` in once. The host's
`swarmctl` reaches the controller through the swarm's gateway as your own SSO account, so every
verb that calls the controller needs this login:
```bash
swarmctl login
swarmctl forge make-admin mara
```
`login` prints a URL and waits for the browser's answer on a loopback port of the machine it runs
on. On a host with no browser, forward a port from the machine that has one, then run the login
with that port:
```bash
ssh -L 8765:127.0.0.1:8765 <host> # on your workstation
swarmctl login --callback-port 8765 # in that ssh session, on the host
```
Open the printed URL in the workstation's browser. The login lasts until the refresh token
expires; `swarmctl` then says to run `login` again.
If the forge already has a local account with your username, the first
SSO login asks for its forge password once, to link the two.

View file

@ -129,7 +129,7 @@ minute it rewrites every agent's key, so a rewrite that failed converges. Ids
are 8 lowercase letters, the same in every agent's key, never reused, and so
never equal to a hive schedule's numeric id.
`swarmctl schedule` calls these routes over the controller's socket:
`swarmctl schedule` calls these routes:
| method | path | body |
| -------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------- |

View file

@ -147,7 +147,7 @@ token. Its access token carries `authelia.bearer.authz` with the audience
`https://<swarm>/api/`, so the gateway admits it at the controller's API and
nowhere else, under the same access rule as a browser session there.
Revocation is per account: once authelia stops accepting the account, the
gateway refuses its token too. See [`swarmctl/README.md`](../../../swarmctl/README.md#remote-use-swarmctl-login).
gateway refuses its token too. See [`swarmctl/README.md`](../../../swarmctl/README.md#reaching-the-controller-swarmctl-login).
## What this doesn't do

View file

@ -66,7 +66,7 @@ swarm-level operator CLI
* `--users-file <PATH>` — Host-side path of authelia's users database — that is, the path inside the container, prefixed with the container's root.
This is the only user store: it's read before every change and written in place, and `swarm-authelia-bridge` writes the same file.
* `--swarm <URL>` — The swarm's domain, as `https://<domain>` or the bare domain. Given, the `agent`, `schedule` and `forge` verbs, and the agent checks and steps of `setup`, go through its gateway as the account `swarmctl login` logged in, instead of over the controller's socket. Falls back to `SWARMCTL_SWARM`; `login` then falls back to `SWARMCTL_LOGIN_DEFAULT_SWARM`, which the swarm-controller nix module sets to its host's own swarm
* `--swarm <URL>` — The swarm's domain, as `https://<domain>` or the bare domain. Given, the `agent`, `schedule` and `forge` verbs, and the agent checks and steps of `setup`, go through its gateway as the account `swarmctl login` logged in, instead of over the controller's socket. Falls back to `SWARMCTL_SWARM`; `login` then falls back to `SWARMCTL_LOGIN_DEFAULT_SWARM`. The swarm-controller nix module sets both to its host's own swarm, so there the verbs use the gateway and need `swarmctl login` once; an empty `SWARMCTL_SWARM` or `--swarm ""` puts them back on the controller's socket
* `--ca-file <PATH>` — A PEM CA certificate to trust beside the system roots, for a swarm whose gateway serves a certificate from the swarm's own CA. Falls back to `SWARMCTL_CA_FILE`
@ -744,7 +744,15 @@ With no `--swarm` or `SWARMCTL_SWARM`, logs in to `SWARMCTL_LOGIN_DEFAULT_SWARM`
Opens the swarm's SSO login in your browser (and prints the URL) and receives the answer on a loopback port, so run it where that browser runs. swarmctl keeps the login, mode 0600, under `$XDG_STATE_HOME/swarmctl/` and refreshes it as it's used. To log out, delete that file.
**Usage:** `swarmctl login`
On a host with no browser, forward the callback port from the machine that has one: `ssh -L 8765:127.0.0.1:8765 <host>`, then run `swarmctl login --callback-port 8765` on the host and open the printed URL in that machine's browser.
**Usage:** `swarmctl login [OPTIONS]`
###### **Options:**
* `--callback-port <PORT>` — The loopback port the login listens on for the browser's answer. Defaults to a free one, which the login prints
Default value: `0`