Skip to content

Allow accesslist cycles pt.1#60034

Merged
hugoShaka merged 3 commits intomasterfrom
hugo/allow-accesslist-cycles
Dec 31, 2025
Merged

Allow accesslist cycles pt.1#60034
hugoShaka merged 3 commits intomasterfrom
hugo/allow-accesslist-cycles

Conversation

@hugoShaka
Copy link
Copy Markdown
Contributor

@hugoShaka hugoShaka commented Oct 8, 2025

This PR:

  • adds a cycle-proof walk function that can be used to traverse the accesslist graph
  • use walk in IsAccessListMember to make it cycle-proof
  • uncomments the cycle tests in hierarchy_test.go

@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from 67b1d70 to 9020ad5 Compare October 8, 2025 14:29
@hugoShaka hugoShaka marked this pull request as ready for review October 8, 2025 14:30
@hugoShaka hugoShaka added the no-changelog Indicates that a PR does not require a changelog entry label Oct 8, 2025
@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from 9020ad5 to 0d3fa5d Compare October 8, 2025 15:33
Copy link
Copy Markdown
Contributor

@smallinsky smallinsky left a comment

Choose a reason for hiding this comment

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

Could you rise a PR with the alignment of design change in terms of access list cycles functionality to the https://github.com/gravitational/teleport/blob/ff91dc086596669fb9e1f1e972b1b13def2f0c9c/rfd/0170-nested-accesslists.md#cycles ?

@kimlisa kimlisa removed their request for review October 9, 2025 19:12
@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from b0fc532 to 75b8217 Compare October 9, 2025 23:11
Copy link
Copy Markdown
Contributor

@smallinsky smallinsky left a comment

Choose a reason for hiding this comment

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

looks reasonable but want to have a final look before approving with fresh head on Monday.

@smallinsky smallinsky self-requested a review October 10, 2025 10:13
Copy link
Copy Markdown
Contributor

@kopiczko kopiczko left a comment

Choose a reason for hiding this comment

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

Round 2

Comment on lines +45 to +50
return visitor{
getter: getter,
seen: make(map[string]struct{}),
stack: []*accesslist.AccessList{accessList},
ctx: ctx,
}.iterate
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm still not a fan of this visitor struct because we pass the context as a field. I understand this is just a fancy way to pass parameters and avoid single indentation level. I guess you can reduce indentation by extracting visitMember/processMember.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was planning to reuse the visitor and add another function to collect owners, hence the dedicated struct. I can get rid of this if this is a blocker.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If it's supposed to be expanded I'm OK with keeping but, but let's not store the context inside the struct, because it creates a potential for it to escape the function call stack.

@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch 3 times, most recently from 7424980 to b9d28bf Compare October 15, 2025 00:10
@hugoShaka hugoShaka requested a review from kopiczko October 15, 2025 00:10
@hugoShaka
Copy link
Copy Markdown
Contributor Author

hugoShaka commented Oct 15, 2025

I updated the PR based on your feedback:

  • the IsAccessListMember function signature now differentiate between "an error happened" and "no valid access path to user, here are some suspects" to make sure we don't misinterpret the error. Every call site was updated.
  • IsAccessListMembernow indicates potential issues (expired memberships, unmet requirements) so we can explain and test access decisions. Some parts of the graph are still filtered out, but we will be able to say "this graph part was ignored because user doesn't meet requirements for list A"
  • the visitor now validates nested access list membership expiry, this is also covered in tests

Things that I will do that are non-blocking for the review:

  • as suggested by @kopiczko: upstream nested expired membership and unmet requirements tests separately, in a PR that will be merged before
  • send a PR to update the nested AL RFD to mention that we will be allowing cycles
  • send 2 other PRs:
    • one for IsAccessListOwner so it uses the same iterator
    • one for GetMembersOf so it uses the iterate with the "allow all" filter function

Note: this PR changes the IsAccessListMember signature and will need some e counterpart.

Copy link
Copy Markdown
Contributor

@smallinsky smallinsky left a comment

Choose a reason for hiding this comment

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

Can we do https://github.com/gravitational/teleport/pull/60034/files#r2419292154

I don't see this as a blocker but for sure it will help the reviewer to understand the behavior change.

@kopiczko @kiosion could you also take a look.

@hugoShaka
Copy link
Copy Markdown
Contributor Author

hugoShaka commented Oct 16, 2025

Can we do https://github.com/gravitational/teleport/pull/60034/files#r2419292154

Tests and signature change are already in their own PR waiting your review:

Once those are merged I will rebase the current PR so the test changes will not show up in the diff.

@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from cabcf84 to 7eeba0c Compare October 20, 2025 20:40
@hugoShaka hugoShaka changed the base branch from master to hugo/nested-al-test-coverage October 20, 2025 20:41
@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from 7eeba0c to cd9bc23 Compare October 20, 2025 20:43
@hugoShaka hugoShaka requested a review from smallinsky October 20, 2025 20:44
Base automatically changed from hugo/nested-al-test-coverage to master October 22, 2025 20:42
@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from cd9bc23 to bfe13f6 Compare October 22, 2025 21:49
Copy link
Copy Markdown
Collaborator

@r0mant r0mant left a comment

Choose a reason for hiding this comment

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

First pass, nothing major from my side so far.

@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from bfe13f6 to 9ca8132 Compare November 18, 2025 15:00
Copy link
Copy Markdown
Contributor

@kopiczko kopiczko left a comment

Choose a reason for hiding this comment

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

I'm thinking the rage function is not a good fit here and the flow suffers because we introduce some patters that are not typical in Go stdlib. But I'm approving regardless because I don't want to get you stuck and visitor is private which means we can rework it without a big penalty.

Having said that, thank you for being patient with the explanations and addressing the comments.

Copy link
Copy Markdown
Contributor

@kopiczko kopiczko left a comment

Choose a reason for hiding this comment

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

Some more minor comments about the visitor internals

@hugoShaka
Copy link
Copy Markdown
Contributor Author

hugoShaka commented Nov 24, 2025

@kopiczko I sent 2 more commits addressing your remaining feedback:

  • storing state in the walk function state instead of the struct
  • moving to walk-like semantics

Can you take another look?

@hugoShaka hugoShaka requested a review from kopiczko November 24, 2025 22:13
@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from d2af26c to 62fafc0 Compare November 24, 2025 22:14
Copy link
Copy Markdown
Contributor

@kopiczko kopiczko left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to rewrite it. To me it looks way easier to follow now.

I left a bunch of comments, but they mostly circle around the same thing.

@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from 62fafc0 to 658c389 Compare December 10, 2025 23:28
@hugoShaka hugoShaka force-pushed the hugo/allow-accesslist-cycles branch from 658c389 to 1404659 Compare December 30, 2025 19:43
@hugoShaka hugoShaka enabled auto-merge December 30, 2025 19:43
@hugoShaka hugoShaka added this pull request to the merge queue Dec 31, 2025
Merged via the queue into master with commit c4f18d4 Dec 31, 2025
44 of 46 checks passed
@hugoShaka hugoShaka deleted the hugo/allow-accesslist-cycles branch December 31, 2025 17:30
21KennethTran pushed a commit that referenced this pull request Jan 6, 2026
* Make IsAccessListMember cycle-proof

* Address final comments

* Lint and error reporting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants