Require set-owner authorization to create OWNER membership
An organization ADMIN could mint an OWNER membership via createUser, which only gated iam:membership-profile:create and bypassed the owner-only iam:membership-role:set-owner check that updateMembership already enforces. Gate the requested role in both createUser entry points (connect resolver and the MCP CreateUserTool) with an additional set-owner authorization when the role is OWNER, mirroring updateMembership. Add a regression test that locks the ADMIN/OWNER privilege boundary the fix relies on. Signed-off-by: Sacha Al Himdani <sacha@probo.com>
This commit is contained in:
@@ -26,6 +26,12 @@ func (r *mutationResolver) CreateUser(ctx context.Context, input types.CreateUse
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if input.Role == coredata.MembershipRoleOwner {
|
||||
if _, err := r.authorize(ctx, input.OrganizationID, iam.ActionMembershipRoleSetOwner); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
profile, err := r.iam.OrganizationService.CreateUser(
|
||||
ctx,
|
||||
&iam.CreateUserRequest{
|
||||
|
||||
@@ -2819,6 +2819,12 @@ func (r *Resolver) CreateUserTool(ctx context.Context, req *mcp.CallToolRequest,
|
||||
return nil, types.CreateUserOutput{}, err
|
||||
}
|
||||
|
||||
if input.Role == coredata.MembershipRoleOwner {
|
||||
if _, err := r.Authorize(ctx, input.OrganizationID, iam.ActionMembershipRoleSetOwner); err != nil {
|
||||
return nil, types.CreateUserOutput{}, err
|
||||
}
|
||||
}
|
||||
|
||||
var contractStart, contractEnd **time.Time
|
||||
if input.ContractStartDate != nil {
|
||||
contractStart = &input.ContractStartDate
|
||||
|
||||
Reference in New Issue
Block a user