RocketChat / RocketChat/Rocket.Chat

REST API - not possible to remove someone from private group unless you are also in this group

Open
#22,865 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triaged
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

I use the REST API to create new user, bringing them in the correct channel, disable them, delete them. All seems to work fine.
To invite a user into a private group where you (the admin) are not a member you need the permission "Add User to Any Private Channel" That works great and helps a lot! - Thanks for that!

But... you can not kick that user anymore. - unless you join that private group with the admin you are using.

Steps to reproduce:
  1. Add someone using the REST API (needs "Add User to Any Private Channel" Permission) to a private Channel where you are not a member

curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
-H "Content-type: application/json" \
http://localhost:3000/api/v1/groups.invite \
-d '{ "roomId": "ByehQjC44FwMeiLbX", "userId": "nSYqWzZ4GsKTX4dyK" }'

  1. Now try to remove the user again

curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
-H "Content-type: application/json" \
http://localhost:3000/api/v1/groups.kick \
-d '{ "roomId": "ByehQjC44FwMeiLbX", "userId": "nSYqWzZ4GsKTX4dyK" }'

  1. See Error Code 400 Bad request

  2. Now join this private group with the callee admin and send the same command from 2. again

  3. See success:true

Expected behavior:

It should be possible to kick someone from a private channel if you are an admin using the API

Actual behavior:

It is a one way ticket. If the user is in that channel you can not kick him anymore.

Server Setup Information:
  • Version of Rocket.Chat Server: 3.17.0
  • Operating System: Ubuntu 18.4.5 LTS
  • Deployment Method: tar
  • Number of Running Instances: 1
  • NodeJS Version: 12.19.0
  • MongoDB Version: 4.0.26

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the REST handlers for groups.invite and groups.kick, then inspect how the "Add User to Any Private Channel" permission is applied when the administrator is not a member. Reproduce the reported sequence and verify that an authorized administrator can remove the invited user without joining the private channel.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, authorization, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.