-
Notifications
You must be signed in to change notification settings - Fork 44
feat(rbac): allow creating orgs to tokens with proper permissions #2703
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
Conversation
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
migmartri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments, I'd like to get some understanding on what's the expected behavior of the org create with both token/users and restrictedCreation/non-restricted
migmartri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please double check my comments
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
I've updated the description with some tests with and without restrict_org_description setting |
migmartri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
| // Restricted org creation is disabled, allow creation | ||
| if !s.authz.RestrictOrgCreation { | ||
| // if org creation restriction is disabled, allow creation to all users | ||
| if !s.authz.RestrictOrgCreation && entities.CurrentUser(ctx) != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, more clear now, thanks
Piskoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, thanks @jiparis !
This PR adds the ability for tokens to create organizations, if they have the "organization:create" policy associated.
I've removed the ad hoc permissions check that this endpoint used to have, and replaced with policy checks, both for users and API tokens.
See some execution logs:
With
restrict_org_creation: false:regular user (Instance Admin): allowed 🟢
regular user (Org Viewer in another org): allowed 🟢
regular API token in a different org: not allowed 🔴
Instance Admin API token: allowed 🟢
With
restrict_org_creation: true:regular user (Instance admin): allowed 🟢
regular user (Org viewer in different org): not allowed 🔴
regular API token from existing org: not allowed 🔴
Instance admin API token: allowed 🟢
Closes #2704