Repository navigation
feat(teams): several owners per team, and roles only from someone who holds them - #114
Merged
Merged
Conversation
… holds them Fixes a privilege escalation: any member with Manage members could give themselves or anyone the Owner role through the API, since assign_member_role checked only that one permission. The same gap let a Manager create a custom role with every permission and assign it to themselves, or invite an account of their own straight in as owner. One rule now gates every path that confers or revokes a role: the actor must hold every permission the role carries, and only an Owner may grant or remove the Owner role. It covers assigning and removing roles, creating, editing and deleting custom roles, add/invite member, and join links. Invites also reject unknown role names now. Several members can hold Owner (VoltiusApp/voltius#652). teams.owner_id becomes the primary owner: the account billing sits on and the only one who can delete the team. It always keeps the Owner role and cannot be removed or leave, so a team always has an Owner. Other Owners can leave. PUT /v1/teams/:id/billing-owner hands it to another Owner. Self-hosted, any Owner may move it. On the cloud only the current primary owner may, and the target needs their own Teams or Business plan at least as high as the current one, with seats for everyone in their teams plus this one (402 otherwise). Ownership changes lock the team row so a transfer cannot race a demotion. /v1/meta advertises multi_owner.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supports VoltiusApp/voltius#652 and fixes a role escalation found while working on it.
Security fix
assign_member_rolechecked onlyPERM_MANAGE_MEMBERS. Managers hold that, so a Manager could call the API and give themselves the Owner role (every permission, Administrator included). The same class of gap let a Manager:owner(invite_memberdid not even validate the role name),New module
team_authority:Authority { permissions, owner }andcovers(). Every path that confers or revokes a role now requires the actor to hold every bit the role carries, and an Owner for the Owner role:require_may_confer_builtin, 400 on an unknown role)Raw role bits are compared on purpose: a bit that is inert alone (VIEW_SECRETS without CONNECT) comes alive next to another role the target holds.
Several owners
teams.owner_idstays and now means the primary owner: the account billing sits on, and the only one who can delete the team.PUT /v1/teams/:id/billing-owner {user_id}hands it to another Owner (409 if they are not one).remove_member, removing the Owner role, the transfer) lock the team row, so a transfer cannot race a demotion of its target./v1/metaadvertisesmulti_owner: true. The client shows the new controls only when it is set.Behaviour change
A custom role that holds Invite members but few other bits can no longer invite someone as
member, becausemembercarries bits it lacks. 30 existing tests used such a role. Their fixtures now usetest_support::inviter_with, which adds the member role's bits.Not in this PR
positionabove their own.Tests
team_authority: property tests.coversis reflexive and transitive and never lets through a bit the actor lacks. Builtin roles cover exactly the roles at or below them.ownership_testsinteams.rs: manager escalation via role, custom role and invite. Owners promote and demote each other. The billing owner is protected. A co-owner can leave.team_ownership: self-hosted vs hosted transfer rights, the target must be an Owner, plan rank, seat cap.