Commit Graph
240 Commits
Author SHA1 Message Date
Kristoffer Dalby 5dff6ca432 policy/v2: resolve user references consistently across updates
Prefer email owners over usernames and validate grants and nodeAttrs on
write. Reject ambiguous writes; log and match nobody on reload. Bare @
matches nobody.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 14baf55421 state, oidc: persist user changes and refresh nodes and clients
Write cleared user columns, discard OIDC email the provider no longer
vouches for, refresh NodeStore users, and notify clients from the callback.

Fixes #3471
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 65a4f0d6fc state, change: notify clients only of effective node changes
Send endpoint and DERP reports only to peers. Suppress redundant online,
policy, and key updates on reconnect or unchanged-key login.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 27bed8f612 state, change: send a deleted node's removal only to its peers
The removal went to every node, also those the policy hid the node from.
The delete now returns the node's peers from the snapshot it replaces.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 14d752cf04 change: coalesce policy recomputes that carry an origin node
The recompute render ignores the origin and always carries the node's
own entry, so a burst of tag writes cost every node one per write.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby ba0ad18e83 state: say a taken name is already taken 2026-11-02 19:15:40 +01:00
Kristoffer Dalby e99ad44064 db, state: keep the ephemeral flag a node was created with
The flag moves from the key to the node, so a login with another key no
longer changes it. A user claiming a tagged node still clears it. v1
nodes carry the flag.

Fixes #3640
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 59f9f78bdd db, types: add a nodes column for the ephemeral flag
The migration fills it from the key each node references.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 8b93e6a074 state: assign and persist unique node names in the NodeStore
Reserve extra DNS names, fit collision suffixes within 63 bytes, and repair
duplicate startup names in memory. Persist registration names without
losing a created node on rename failure; remove unused DB renaming.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 0cc518b95e state: test that a persist racing a delete cannot resurrect the node
DeleteNode's early persistMu unlock is safe only while node persists
stay UPDATE-only; say so where the lock is declared.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 3038aa907a mapper: show an expired peer online, without endpoints or DERP
A connected expired node shows online to its peers. Neither its map
entry nor endpoint, DERP or disco patches carry the paths to reach it.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 99e8a9228a mapper: trim the Hostinfo sent to peers and to the node itself
As on Tailscale SaaS, the node's own entry keeps Hostname, RequestTags,
RoutableIPs and Services; peers get Hostname, OS, Services without
peerapi-dns-proxy, SSH host keys and AppConnector, and resend on those.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 06a0dcd62d state: apply requested tags on a key login that owns them
A requested tag the key's user owns directly, or the key's tags own one
hop away, replaces the key's tags instead of refusing the login.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 6876bcfa7f state: maintain auto-approvals across route and tag changes
Withdrawal removes approvals granted only by policy; manual and migrated
approvals remain. Recheck routes after policy learns an administrator's
new tags.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby bdfe6fc380 db, types: add a column for auto-approved routes
It starts empty: the current policy cannot tell which earlier approvals
were automatic, so all of them stay as an admin's.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 6fe62dec62 state: auto-approve on registration only when the node key rotates
Registration runs the approval itself, once the policy manager knows the
node's owner, for a new node key or a change to the announced routes.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby e84615049e auth, state: preserve client expiry and require expired node key rotation
Return NodeKeyExpired for same-key login so the client rotates its key;
the machine stays authorized. Store earlier client expiry and expire
tagged nodes at logout.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby ba319ba8c4 state: invalidate SSH check approvals on owner changes and expiry
Honor approval only while its source keeps the same owner and is live.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby b1ab98bde9 state: let a pre-auth key that is no longer valid only wake its node
A login that keeps its node key leaves a live node's expiry alone, even
with a valid key, and a wake-up is not refused for the tags it requests.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby d67ee0bd75 state: serialise registrations presenting an unused single-use key 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 3e9195e4d6 state: auto-approve routes in the NodeStore writer, not on reload
Registration approval runs on the node the writer replaces. A policy
reload approves nothing, and a map request only when its announced
routes change, so neither re-grants a route an admin revoked.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby bd74ce670e state: persist current NodeStore rows and roll back only failed writes
Read current NodeStore rows under persistMu. Roll back only fields still
matching the failed registration, preserving concurrent node changes.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 221a387b2b state: apply map requests only under the node key that authorised them 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 256a67e86b policy: offer exit routes only to viewers whose rules reach the internet
Every destination overlaps /0, so any rule offered a peer's exit routes.
They now need a rule to the internet, the test exit-node visibility
uses; via steering defers them to a regular grant only on that test.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 05039d3398 policy, state: log only the routes auto-approval adds 2026-11-02 19:15:40 +01:00
Kristoffer Dalby 71dc0c1c58 types, state: derive and reduce approved routes once
Derive subnet and exit routes together, once each in announcement order.
Reuse matcher membership while preserving HA co-router visibility.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 0e7515eab9 state, policy/v2: classify only effective route changes
Compare announced-and-approved routes only when immutable route inputs
change. Publish Hostinfo without unnecessary peer adjacency rebuilds.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 4342883bd4 policy/v2, state: elect primaries by oldest control session
A router that reconnects joins as a standby; one that kept its session
takes its routes back once available again, as on Tailscale. Both the
global and the via election use it, in place of anti-flap stickiness.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 555caf7c2b types: add when a node's run of control sessions began 2026-11-02 19:15:40 +01:00
Kristoffer Dalby e0717bc116 state, policy/v2: elect available routers and retain unavailable routes
Recompute via elections on health changes and check online state and expiry.
With no available router, retain the previous primary or lowest-ID approver;
exclude routers the prober marked unreachable.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 25a01070e9 state: keep HA health probes active without delaying unrelated routers
Probe lone unhealthy advertisers. Defer results only for routers whose
routes tie them to a router still awaiting its probe.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby f2df44295a state, db: validate and store the current policy before installing it
Reject empty input. Validate without changing live state, then store and
install under one lock; prune old rows only with a successful write.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 033dcdf43b state: serialise policy reloads
Load and install the stored policy as one step, so an older
reload cannot install its document over a newer one.
2026-11-02 19:15:40 +01:00
Kristoffer Dalby 1318f2802f servertest, state: add node name golden data
Labels under taken hostnames, case-only renames, hostname changes, long
hostnames and a Service's name; API, peer and self per step, and State
labels as a restart would load them.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby 46b84d47fe servertest, state: add map delivery golden data
A retag through the API, a running peer's DERP, disco, hostname and
port, down and up gaps around policy pushes; peers, filters and frames
per node.
2026-11-02 16:09:00 +01:00
Kristoffer Dalby c0925962c2 hscontrol: bound pending authentication without evicting sessions 2026-10-29 20:51:50 +01:00
Kristoffer Dalby b5bebf9b32 db, state: let only the delete that removed a node free its addresses
Fixes ANT-2026-NWTIBB02
2026-10-29 14:00:02 +01:00
Kristoffer Dalby c9e9f72857 state: drop registration locks once unused
The lock is taken before any credential check, so client-chosen machine
keys grew the map forever. Ref-count entries; delete at zero.

Fixes ANT-2026-ZC18AF82
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 5a4d366ce1 auth, state: keep only hostname, OS and tags in pending registrations
The rest arrives with the first MapRequest. A relogin keeps the node's
current Hostinfo, endpoints and disco key; an oversized merge is a 400.

Fixes ANT-2026-RQS7JAPP
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 4ce928411e state: bound client reports of nodes loaded at startup
Rows stored before the bounds are trimmed the same way at load; a
Hostinfo still over budget is dropped until the node reports again.

Fixes ANT-2026-RQS7JAPP
Fixes ANT-2026-5B6KE87K
Fixes ANT-2026-KFCFFM34
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 15a8c7584e hscontrol: refuse a key expiry that cannot be encoded
handleRegister, the OIDC auth path and SetNodeExpiry refuse it. Expiries
are stored in UTC, which SQLite can read back, and loaded in UTC, as
PostgreSQL returns the server's zone. The v1 API answers 400.

Fixes ANT-2026-QMCAFJ1Q
2026-10-29 14:00:02 +01:00
Kristoffer Dalby e3c1bfd68e mapper: skip peers whose key expiry cannot be encoded
json.Marshal refuses a year outside [0,9999], so one stored expiry
failed every map with that node. TailNode and key patches send UTC, the
builder drops what fails and the boot scan names the node.

Fixes ANT-2026-QMCAFJ1Q
2026-10-29 14:00:02 +01:00
Kristoffer Dalby e1de83cbdf state: give another user's key on a tagged machine a new device
Only a key that speaks for a tagged node re-authenticates it: a tagged
key, or one of the user it was tagged from. Another user's key or login
adds that user's own device, or only wakes the node under its node key.

Fixes ANT-2026-AWGRB7O1
2026-10-29 14:00:02 +01:00
Kristoffer Dalby e67ef8619a state: need a valid pre-auth key to re-register an expired tagged node
Fixes ANT-2026-LYVGXVSW
2026-10-29 14:00:02 +01:00
Kristoffer Dalby 47d82023e7 state: never serve a single address inside the node ranges
Such a route names a node, not a subnet: it stays approved and listed
but no viewer gets it. Via inclusions skip the election, so the rule
sits on everything RoutesForPeer returns.

Fixes ANT-2026-MLP8ZR5T
2026-10-29 14:00:02 +01:00
Kristoffer Dalby a63ee3e032 api/v2: add the acl/validate endpoint
Checks a policy as a write would, without storing it. As on Tailscale,
a refused policy answers 200 with its reason; only an empty body is 400.
Terraform provider 0.29.3 calls it at plan time.
2026-10-29 11:04:05 +01:00
Kristoffer Dalby cd62031b98 state: stop the auth cache TTL sweeper on Close
The expirable LRU ran its sweeper forever, one goroutine per State. Purge
first so pending waiters get ErrRegistrationExpired instead of hanging.
The OIDC state cache is closed at server shutdown for the same reason.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby 51b420865e state: own request memory before storing nodes
A reused RegisterRequest.Hostinfo was written and stored while NodeStore readers cloned it.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby 552356a2ee state: skip the caller's policy refresh once the writer applied it
The writer refreshes the policy manager before publishing its batch, so
the caller's SetNodes with the published snapshot recompiled it back.
2026-10-23 18:23:53 +02:00
Kristoffer Dalby 5d21186f22 state: release persistMu before the NodeStore delete
Holding it serialised concurrent deletes into one NodeStore batch and
peer map build each, capping deletion at one batch tick per node.
2026-10-23 18:23:53 +02:00