Skip to content

policy: allow tags to own tags - #2930

Merged
kradalby merged 4 commits into
juanfont:mainfrom
kradalby:kradalby/tags-in-tags
Dec 6, 2025
Merged

kradalby merged 4 commits into
juanfont:mainfrom
kradalby:kradalby/tags-in-tags

Conversation

@kradalby

@kradalby kradalby commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator

As per Tailscale's implementations, Tags are allowed to
own other tags.

Closes #2866

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements support for tags to own other tags in the policy system, allowing a hierarchical ownership structure for tag management. This aligns with Tailscale's implementation where tags can be specified as tag owners, enabling more flexible access control patterns.

Key changes:

  • Added flattenTagOwners and flattenTags functions to resolve tag ownership chains and detect circular references
  • Extended the Owner interface and related serialization logic to support Tag as an owner type
  • Updated resolveTagOwners to handle flattened tag ownership hierarchies

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
hscontrol/policy/v2/types.go Core implementation: added circular reference detection, tag flattening logic, and Tag support in Owner serialization
hscontrol/policy/v2/types_test.go Comprehensive test coverage including circular reference detection, tag ownership chains, tag resolution, and alignment fixes for IPv4 fields
hscontrol/policy/v2/policy_test.go Minor formatting fixes for User/UserID pointer consistency
hscontrol/auth_test.go Refactored to use TypedID() method instead of direct type conversion
CHANGELOG.md Added entry documenting the new feature
Comments suppressed due to low confidence (1)

hscontrol/policy/v2/types.go:998

  • The error message says "An alias must be one of the following types" which is misleading since this is for Owner types, not Alias types. Consider changing to "An Owner must be one of the following types:"
	return nil, fmt.Errorf(`Invalid Owner %q. An alias must be one of the following types:
- user (containing an "@")
- group (starting with "group:")
- tag (starting with "tag:")

Please check the format and try again.`, s)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hscontrol/policy/v2/types.go
Comment thread hscontrol/policy/v2/types.go
Comment thread hscontrol/policy/v2/types_test.go Outdated
},
},
nodes: types.Nodes{
// Should not match as we resolve the "child" tag.

Copilot AI Dec 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is contradictory. It says "Should not match" but the test expects this node's IP (100.100.101.234) to be in the result (line 1776). The comment should say "Should match as we resolve the 'parent' tag."

Suggested change
// Should not match as we resolve the "child" tag.
// Should match as we resolve the "parent" tag.

Copilot uses AI. Check for mistakes.
Comment thread hscontrol/policy/v2/types_test.go Outdated
Comment thread hscontrol/policy/v2/types.go
@kradalby
kradalby force-pushed the kradalby/tags-in-tags branch from 14ea802 to 8d59f34 Compare December 4, 2025 14:38
kradalby and others added 3 commits December 4, 2025 19:00
As per Tailscale's implementations, Tags are allowed to
own other tags.

Closes juanfont#2866

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
Signed-off-by: Kristoffer Dalby <kristoffer@dalby.cc>
@kradalby
kradalby force-pushed the kradalby/tags-in-tags branch from 8d59f34 to 4420935 Compare December 4, 2025 19:00
@kradalby
kradalby requested review from juanfont and nblock December 5, 2025 12:50
@kradalby
kradalby merged commit 15c84b3 into juanfont:main Dec 6, 2025
190 of 193 checks passed
@nblock nblock added this to the v0.28.0 milestone Dec 6, 2025
EdGeraghty added a commit to privacyint/headscale-admin that referenced this pull request Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tags cannot owner other tags

3 participants