-
Notifications
You must be signed in to change notification settings - Fork 44
feat(rbac): allow tokens to create org invitations and storage backends #2710
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>
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>
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>
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
| // 2.c - Set its user | ||
| usercontext.WithCurrentUserMiddleware(opts.UserUseCase, logHelper), | ||
| // Store all memberships in the context | ||
| usercontext.WithCurrentMembershipsMiddleware(opts.MembershipUseCase), |
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.
I just moved this earlier in the chain, so that membership is available to the middlewares in the next selector.
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
| } | ||
|
|
||
| // 3 - Check that the user is a member of the given org | ||
| // NOTE: this check is not necessary, as the user is already a member of the org |
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.
As the comment states, this is not needed since validation is done in the middleware layer already.
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
| @@ -0,0 +1,2 @@ | |||
| -- Modify "org_invitations" table | |||
| ALTER TABLE "org_invitations" ALTER COLUMN "sender_id" DROP NOT NULL; | |||
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.
why is this?
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.
The sender is now optional (instance tokens are anonymous)
Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>

For easy onboarding, this PR includes the RBAC logic to allow Tokens with proper permissions to create organization invitations (initially only
InstanceAdminRole), and list and create storage backends.Also, for InstanceAdmin users, they will be allowed to invite users to orgs they don't belong to.
Some tests:
Organization invitations
With Instance admin token: 🟢
Then authenticate with the target user:
With Instance admin user: 🟢
With regular token: 🔴
With regular user (Org Member): 🔴
Same user trying to invite someone to an org he doesn't belong to (but exists):
With regular user (org admin): 🟢
Storage backends
Regular user (Org Owner): 🟢
Regular user (Org Viewer): 🔴
Regular user (Instance admin, not member of the target org): 🟢
Token (instance admin)⚠️
Without org:
With org: 🟢
Regular token: 🔴
Refs #2704