Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AccessList Proto, AccessList & AccessListMember types, add Hierarchy utils #47828

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

kiosion
Copy link
Contributor

@kiosion kiosion commented Oct 22, 2024

  • Add Hierarchy utils for nested AccessList validation and handling
  • Update AccessList Protos with new fields
  • Update AccessList and AccessListMember types and converters with new fields

Split from #38738.

@kiosion kiosion added the no-changelog Indicates that a PR does not require a changelog entry label Oct 22, 2024
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-47828.d3pp5qlev8mo18.amplifyapp.com

This comment was marked as outdated.

Copy link

🤖 Vercel preview here: https://docs-b8sev9aux-goteleport.vercel.app/docs/ver/preview

Copy link

🤖 Vercel preview here: https://docs-8mejpmy5t-goteleport.vercel.app/docs/ver/preview

Copy link

🤖 Vercel preview here: https://docs-ia3ox80t5-goteleport.vercel.app/docs/ver/preview

@public-teleport-github-review-bot

@kiosion - this PR will require admin approval to merge due to its size. Consider breaking it up into a series smaller changes.

Copy link

🤖 Vercel preview here: https://docs-kpk92pprv-goteleport.vercel.app/docs/ver/preview

@@ -71,6 +71,12 @@ message AccessListSpec {

// owner_grants describes the access granted by owners to this Access List.
AccessListGrants owner_grants = 11;

// owner_of describes Access Lists that this Access List is an explicit owner of.
repeated string owner_of = 12;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to keep track of this information for every access list?

Copy link
Contributor

Choose a reason for hiding this comment

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

My concern here is that AL being imported by sync utils will have to preserve these fields when they grant access to Teleport access lists.
If we don't need to specify these here and can compute them when needed, it would be much better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, these need to be tracked for every list. I don't love either option... computing when needed is what was initially implemented, but it was much more expensive and required passing around all existing access lists for checks

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we store it under different keys if the goal is to keep it internal?

Or move it to the status field

Copy link
Contributor

Choose a reason for hiding this comment

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

Status aren't meant to be edited by users and you can always keep the state there. We can probably keep some logic to keep it when reconcilers run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the status field persisted?

Copy link
Contributor

@tigrato tigrato Oct 28, 2024

Choose a reason for hiding this comment

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

Yes, we persist status fields and the operator/terraform skips them IIRC

Copy link
Collaborator

Choose a reason for hiding this comment

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

No objections from me to moving these fields to status as users aren't supposed to set them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved them into status, it wasn't persisted previously so I named the json/yaml field as status and set the member/nested list count fields within it to -. LMK if it looks good

Copy link

🤖 Vercel preview here: https://docs-971v2tura-goteleport.vercel.app/docs/ver/preview

Comment on lines 288 to 294
if a.Spec.OwnerOf == nil {
a.Spec.OwnerOf = []string{}
}

if a.Spec.MemberOf == nil {
a.Spec.MemberOf = []string{}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the code flow distinguish between nil and []string{} array ?

Comment on lines +213 to +207
// membership_kind describes the type of membership, either
// `MEMBERSHIP_KIND_USER` or `MEMBERSHIP_KIND_LIST`.
MembershipKind membership_kind = 9;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like according to proto field order it should field nr. 8

Suggested change
// membership_kind describes the type of membership, either
// `MEMBERSHIP_KIND_USER` or `MEMBERSHIP_KIND_LIST`.
MembershipKind membership_kind = 9;
// membership_kind describes the type of membership, either
// `MEMBERSHIP_KIND_USER` or `MEMBERSHIP_KIND_LIST`.
MembershipKind membership_kind = 8;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iirc there was a reason it was set to field 9, let me see if I can find it..

Comment on lines -289 to -291
if len(a.Spec.Grants.Roles) == 0 && len(a.Spec.Grants.Traits) == 0 {
return trace.BadParameter("grants must specify at least one role or trait")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this validation change is intended ?

This change will allow to create a access list without any grants role and traits role.

Copy link
Contributor Author

@kiosion kiosion Oct 28, 2024

Choose a reason for hiding this comment

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

Yes, creating a list without any roles or traits was part of the initial RFD

lib/accesslists/hierarchy.go Outdated Show resolved Hide resolved
lib/accesslists/hierarchy.go Outdated Show resolved Hide resolved
lib/accesslists/hierarchy.go Outdated Show resolved Hide resolved
- Add Hierarchy utils for nested AccessList validation and handling
- Update AccessList Protos with new fields
- Update AccessList and AccessListMember types and converters with new
  fields
Copy link

🤖 Vercel preview here: https://docs-om8ctwyn8-goteleport.vercel.app/docs/ver/preview

@@ -268,6 +287,12 @@ message ReviewChanges {

// AccessListStatus contains dynamic fields calculated during retrieval.
message AccessListStatus {
// member_count is the number of members in the in the Access List.
// member_count is the number of members in the Access List.
optional uint32 member_count = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the total number of users including users that have access to it through nested access lists or just direct access list memberships?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just direct memberships.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make it clear?

@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from zmb3 October 29, 2024 15:54
@kiosion kiosion added this pull request to the merge queue Oct 30, 2024
Merged via the queue into master with commit a0540c5 Oct 30, 2024
46 checks passed
@kiosion kiosion deleted the maxim/nested-acl-protos branch October 30, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation helm no-changelog Indicates that a PR does not require a changelog entry size/xl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants