Extending starmole
On this page
starmole itself stays small: a daemon, a config file and keys. Everything a bigger setup needs, like signing in through your identity provider, company-wide policy or a view of who connects where, goes on top as separate programs. I want to keep using the small version myself, and nothing here should make it bigger.
Extensions are programs starmole runs, or programs that talk to the daemon's socket. There's no plugin runtime and nothing gets loaded into the daemon. The idea is the same as git's credential helpers or kubectl's exec plugins: a command, a few environment variables, text in and text out.
A program can also be a node itself, built on the
starmole crate, serving protocols of its own with the same
certificates and rules as everything else. See Building on starmole.
The rule
An extension can tell starmole who a peer is, or say no. It can never
let a peer do more than this machine's [[allow]] rules give
it.
That keeps the answer to "what can get into my machine?" the same with or without extensions: a peer whose identity checks out against something this machine trusts, doing what this machine's rules allow. An identity provider, a policy engine or a hosted service can only narrow that.
Something other than the machine has a say in two places. In the first, whoever signs certificates decides who is in which group, and machines decide what a group may do. The network key bounds the signer, since an issuer certificate lists the names, tags and groups it may hand out and for how long, and machines refuse anything outside that. The second is signed rules (seam 6 below), which a machine takes only when its own config says so.
The seams
Six places where something can plug in. The first three exist today, and the sixth in part.
1. Getting this node's credential
[credential] helper is a command that gets this node a
credential, usually by signing its key somewhere you already sign SSH
keys: Vault, step-ca, your own ssh-keygen CA.
starmole login runs it and installs what it prints. See setup.
The command gets:
| stdin | this node's key as an OpenSSH public key line, the same as
starmole id --ssh |
STARMOLE_NODE_ID |
this node's id |
STARMOLE_NETWORK |
the network id, if one is set |
It prints anything starmole cert install takes: an SSH
certificate, or a certificate from the network key. Its stderr goes to
your terminal, so it can ask you to sign in. A non-zero exit means it
didn't work.
The helper runs as you, with your browser and your tokens. The daemon never runs it and never holds what it signs in with.
2. Offering something by name
A program on a machine becomes a service with a few lines under
[services.<name>], and members with a
service:<name> cap open it with
starmole open machine/name. With
identity = true the program gets a line of JSON saying
who's connecting before their data, so it can treat people differently
without any login of its own. See setup.
A program can also be a whole node and serve protocols of its own; see Building on starmole.
3. Trading proof for a certificate
A machine joins with a bare certificate, or none, and can't do anything: no rule matches it. To get access it goes to an auth service on the network, shows it something (a sign-in at your identity provider, an SSH certificate, a passkey, someone's approval) and gets a short-lived certificate back with the groups that proof is worth. From then on every machine checks that certificate like any other, offline.
The auth service runs a verifier for each kind of proof. That keeps OIDC, passkeys and whatever else comes along on the auth services, which are few, while the other machines keep checking one kind of certificate. The auth service only has to be up when someone signs in. See the exchange below.
Machines that should work without an issuer can still trust an SSH CA
directly with [network] ssh_ca.
4. Saying no (planned)
An authorizer is asked after the local rules have said yes, with the peer's identity and what it wants to do: a shell as which user, a forward to where. It answers yes or no. This is where OPA, Cedar or a script that checks an on-call schedule would go. It can't widen anything, so a broken or compromised authorizer can only lock people out.
5. Watching what happens (planned)
The connection log as a stream over the socket: the same JSON lines
starmole log reads, as they happen. A traffic view, a
forwarder to your SIEM or alerts on odd connections all read from
it.
6. Policy for many machines (partly built)
Revocation lists and the network policy spread through the network
signed by the network key, without a server. The policy names the auth
services, whether sign-in is required, and signed [[allow]]
rules for the machines that take them (see How it works).
Each machine checks the signature before using any of it, and its own
config.toml decides whether it takes signed rules at all.
Not built: time-limited grants, and signing policy kept in a repository
from CI.
The exchange
How seam 3 works.
Naming an auth service
On the machine holding the network key:
starmole net auth add auth --kinds ssh --names '*' --groups 'eng,oncall' --users --max-ttl 12hThat signs auth an issuer certificate with those limits
and puts it in the network policy, which every machine has within
seconds. starmole net auth list shows the auth services and
what each may sign. starmole net auth remove auth takes one
out and revokes its issuer certificate, so what it signed stops working
too.
On the auth service
It needs a verifier for each kind it takes:
[exchange]
ttl = "12h" # the longest certificate a sign-in gets; 12h is the default
[exchange.verifiers]
ssh = "starmole-verify-ssh --ca /etc/starmole/user_ca.pub"Anyone may connect, the way anyone may redeem an invite; the proof is what counts. The certificate is always for the key that connected.
A verifier is any program. It gets {"proof": "..."} as
its first line on stdin, and STARMOLE_PEER (the node id
signing in), STARMOLE_NETWORK and
STARMOLE_KIND in its environment. It answers with one JSON
object per line:
| Line | Meaning |
|---|---|
{"show": "Sign in at https://sso.example.com/device with code WDJB-MJHT"} |
shown to the person signing in |
{"ask": {"text": "One-time code", "secret": true}} |
asked of them; the answer comes back on stdin as
{"answer": "492817"} |
{"claims": {"user": "alice", "groups": ["eng"], "ttl": 3600}} |
the proof checks out |
{"refuse": "not in the eng team"} |
it doesn't |
claims may have name, user,
groups, tags and ttl (seconds).
The auth service keeps the name, tags and addresses of the machine's
current certificate, adds the claims, cuts the result down to what its
issuer certificate allows and to [exchange] ttl, and signs.
Leave name out unless the verifier knows the machine, like
one that looks its key up in a fleet's records. Rules can match names,
so the issuer certificate should limit names to that fleet's pattern
(--names 'node-*'). A device-flow sign-in at an identity
provider is a verifier that shows a URL and waits; one that checks a
password and a one-time code asks twice. Either way the program runs on
the auth service, so the machines signing in need nothing but
starmole login.
Every sign-in shows up in starmole log as
exchange.issued or exchange.refused, with the
kind and the name or reason. At most 16 run at once.
On the machine signing in
$ starmole login
It finds the auth service in the network policy. If
[credential] helper is set, its output is the proof, so an
SSH certificate from Vault or step-ca goes straight to an auth service
that takes ssh. --with oidc picks a kind when
there are several.
A certificate from a sign-in isn't renewed. When it runs out, sign in
again, or set [credential] renew on a server so the daemon
does it.
What I still need to decide
- Proof that isn't bound to the key. An SSH certificate names the key
it's for. An OIDC token a machine brings usually doesn't, so a stolen
token would get the thief a certificate.
starmole-oidcavoids that by running the device flow itself, so the token never leaves the auth service. A verifier that takes tokens from machines would need something like DPoP. - Quiet renewal while the identity provider session lasts, so signing in happens once a day rather than once per certificate.
- Tighter limits for users. An issuer certificate limits names, tags and groups by pattern, but only says whether its holder may name users at all, not which ones, like "users ending in @example.com".
A hosted exchange
This is also how a hosted service could hand out access without being
able to get in on its own. You sign it an issuer certificate with your
network key that only allows, say, group:contractors for at
most an hour, and your machines' rules give that group very little. The
service can't hand out anything beyond that, because every machine
checks the issuer certificate. Within those limits it could sign in as
anyone it likes, and that's the part you'd have to trust it with.