headscale/hscontrol/policy/v2
Kristoffer Dalby a4f05b0962 policy/v2: parse, validate, and compile nodeAttrs
ACL policies now accept a top-level nodeAttrs block. Each entry hands
a list of tailcfg node capabilities to every node matching target.
Accepted target forms are the same as acls.src and grants.src: users,
groups, tags, hosts, prefixes, autogroup:member, autogroup:tagged,
and *. autogroup:self, autogroup:internet, and autogroup:danger-all
are rejected at validate time because none describes a stable
identity set a node-level attribute can attach to.

NodeAttrGrant carries Targets, Attrs, and IPPool. IPPool is parsed
but rejected at validate time -- the allocator that consumes it is
not yet implemented. nodeAttrUnsupportedCaps lists caps SaaS accepts
that headscale cannot act on (funnel today) and rejects them with a
tracking-issue link in the error.

compileNodeAttrs resolves each entry's targets, then maps every
targeted node to a tailcfg.NodeCapMap of the entry's attrs. Per-node
IPs are cached once per call so the inner attr loop is O(grants)
instead of O(grants * nodes) IP allocations.

PolicyManager grows NodeCapMap (per-node), NodeCapMaps (snapshot for
batched callers), and NodesWithChangedCapMap (drain buffer for the
self-broadcast diff). refreshNodeAttrsLocked appends to the drain
rather than overwriting so a SetUsers/SetNodes between SetPolicy and
the drain cannot lose the policy-reload diff.
2026-05-13 14:22:30 +02:00
..
testdata policy/v2: add policytester captures recorded from Tailscale SaaS 2026-05-12 11:54:54 +01:00
compiled.go policy/v2: parse, validate, and compile nodeAttrs 2026-05-13 14:22:30 +02:00
filter.go policy: surface exit nodes via autogroup:internet (#3212) 2026-04-29 11:24:33 +01:00
filter_test.go policy/v2: surface autogroup:internet via grants on exit nodes 2026-04-30 19:22:45 +01:00
issue_3212_test.go policy: surface exit nodes via autogroup:internet (#3212) 2026-04-29 11:24:33 +01:00
issue_3233_test.go policy/v2: surface autogroup:internet via grants on exit nodes 2026-04-30 19:22:45 +01:00
main_test.go all: fix test flakiness and improve test infrastructure 2026-03-14 02:52:28 -07:00
nodeattrs_test.go policy/v2: parse, validate, and compile nodeAttrs 2026-05-13 14:22:30 +02:00
policy.go policy/v2: parse, validate, and compile nodeAttrs 2026-05-13 14:22:30 +02:00
policy_test.go policy/matcher: include CapGrant.Dsts in match destinations 2026-05-11 14:55:06 +01:00
policytester_compat_test.go policy/v2: match default proto set for tests with no proto 2026-05-12 11:54:54 +01:00
tailscale_acl_data_compat_test.go all: rephrase prose to fit codebase voice 2026-04-29 16:22:19 +01:00
tailscale_grants_compat_test.go all: rephrase prose to fit codebase voice 2026-04-29 16:22:19 +01:00
tailscale_routes_data_compat_test.go all: rephrase prose to fit codebase voice 2026-04-29 16:22:19 +01:00
tailscale_ssh_data_compat_test.go testdata: drop unused uppercase SSH-*.hujson fixtures 2026-05-05 11:59:01 +01:00
test.go policy/v2: match default proto set for tests with no proto 2026-05-12 11:54:54 +01:00
test_test.go policy/v2: match default proto set for tests with no proto 2026-05-12 11:54:54 +01:00
types.go policy/v2: parse, validate, and compile nodeAttrs 2026-05-13 14:22:30 +02:00
types_test.go policy/v2: canonicalize Protocol form during unmarshal 2026-05-12 11:54:54 +01:00
utils.go policy/v2: exclude exit routes from ReduceFilterRules 2026-04-01 14:10:42 +01:00
utils_test.go policy/v2: exclude exit routes from ReduceFilterRules 2026-04-01 14:10:42 +01:00