Skip to content

Conversation

@vdovhanych
Copy link
Contributor

@vdovhanych vdovhanych commented Sep 30, 2025

  • have read the CONTRIBUTING.md file
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

This adds the autogroup:self feature and should close #2618

While the feature should now work, I still feel it needs a bit more work to be "production" ready. I am concerned about the headscale's performance when this autogroup is used in the ACL.

Update1:
I added and updated the documentation for the ACL rules, listing supported autogroups and providing some examples of usage.

Update2:
I was trying out the build on some test environments when I realized that SSH would not work with the autogroup:self and that it also needed special handling for filtering the nodes. I tried to address it with ddf4cc6

Update3:
changed some stuff again for the SSH rules to work with autogroup:self (this was done after I tried to evaluate adding the feature with the AI agent, this was a suggestion, but it would not work without it) 80fba7a

Copy link
Collaborator

@nblock nblock left a comment

Choose a reason for hiding this comment

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

Thank you very much for tackling autogroup:self and also documenting it!

Left a few minor comments and suggestions.

docs/ref/acls.md Outdated

Includes devices where the same user is authenticated on both the source and destination. Does not include tagged devices. Can only be used in ACL destinations.

Available as of [#2789](https://github.com/juanfont/headscale/pull/2789).
Copy link
Collaborator

Choose a reason for hiding this comment

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

See above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the line completely, not really needed there.

// invalidateAutogroupSelfCache intelligently clears only the cache entries that need to be
// invalidated when using autogroup:self policies. This is much more efficient than clearing
// the entire cache.
func (pm *PolicyManager) invalidateAutogroupSelfCache(oldNodes, newNodes views.Slice[types.NodeView]) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure how easy, but would be nice to have some tests for this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't be that hard, i'll write a test for this functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@kradalby kradalby left a comment

Choose a reason for hiding this comment

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

One comment, otherwise I'm happy with letting this in to let it be tested.

I think we should write up in the changelog that this is an experiment and that you as a user needs to be careful and help test it and that they must understand that a bug might give more access than what is expected.
And a note about that it is quite computational expensive.

Copy link
Collaborator

@kradalby kradalby left a comment

Choose a reason for hiding this comment

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

Let's take it for a spin!

@kradalby kradalby merged commit c2a58a3 into juanfont:main Oct 16, 2025
80 of 87 checks passed
@vdovhanych vdovhanych deleted the group-self branch October 16, 2025 13:20
@benley
Copy link
Contributor

benley commented Oct 16, 2025

I've been looking forward to this one, thank you for making it happen!

@vdovhanych
Copy link
Contributor Author

vdovhanych commented Oct 16, 2025

I've been looking forward to this one, thank you for making it happen!

Same here @benley 😆
Because of that i decided to take up on the challenge of building this. Hopefully it works well.

@danscarfe
Copy link

Hip, hip hooray. Thanks all!

@Haarolean
Copy link
Contributor

@vdovhanych thanks for implementing this! ❤️

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.

Policy: autogroup support

6 participants