spacebarchat / server

Spacebar server - A reimplementation of the Discord.com backend, built with Typescript and love
https://spacebar.chat
GNU Affero General Public License v3.0
1.41k stars 242 forks source link

Controlled accounts #171

Open erkinalp opened 3 years ago

erkinalp commented 3 years ago

Is your feature request related to a problem? Please describe. Companies, schools and parents would like ability to white- and black- list certain users to certain guilds, channels and user groups. Bridge bots could also make use of this feature.

Describe the solution you'd like

Detailed description of the endpoints

Create controlled account: This endpoint shall create a controlled user account. Parameters:

Delete controlled account: This endpoint shall remove a controlled user account.

Parameters: same as /users/@me/delete, but controlled accounts cannot initiate account delete on their own. Returns: If unauthorised to delete the user or apply one or more of the control flags, return 403 Forbidden. On attempt to delete a non-existent user in a discriminator range controlled by said user, return 400 Bad Request. On success, return 200 OK.

Group white- and blacklist objects: Parameters:

Group whitelist/blacklist create:

If unauthorised to create a controlled user or apply one or more of the control flags, return 403 Forbidden. On success, return 200 OK.

Discriminator range reserve: Reserve certain discriminators for a certain account controller. An account controller can only reserve discriminators for itself, not for other controllers. Parameters:

If unauthorised to create a controlled user or apply one or more of the control flags, return 403 Forbidden. On success, return 200 OK.

Discriminator range fetch: Returns the reservation by reservation ID. Discriminator range reservations shall be returnable by any user.

If unauthorised to create the reservation or attempts to re-reserve an already reserved range, return 403 Forbidden. On success, return 200 OK.

Discriminator range delete: Deletes the reservation by reservation ID. Only the user that created the reservation can delete it.

If unauthorised to unreserve the range, return 403 Forbidden. On attempt to delete a non-existent reservation, return 400 Bad Request. On success, return 200 OK.

Apply group white/blacklist to controlled user: Applies group scope limits to a given user. Parameters:

Sub-tasks

SamuelScheit commented 3 years ago

I think this is especially useful for schools and organizations/companies who want to provide an easy way to signup their employees/pupils/members. I think can_edit_self should be controlled in a more general way, that instance owners can create certain types of users (flags/badges) that have instance-wide permissions. Also I'm not sure if the accounts should be bound to a certain controller it rather should be the instance admin. I think many ideas could be adapted in a more general way. (e.g. an admin should be able to block/delete any account)

SamuelScheit commented 3 years ago

Action in behalf of controlled user

What kind of actions?

erkinalp commented 3 years ago

Also I'm not sure if the accounts should be bound to a certain controller it rather should be the instance admin.

In the model I had in mind, server administrator would approve the account controller privileges, and controllers would administer those accounts.

What kind of actions?

Any, but can be scoped further by permission bits. This will be handy in implementing puppeting bridges.

an admin should be able to block/delete any account

Account controllers are something separate from server administrators, and will not have direct database access.

DiegoMagdaleno commented 3 years ago

Users should be able to claim this account, so the way we could do this is by linking the IDs of the Discord account with the Fosscord account. Then when the user wants to "migrate" fosscord, we could give two options to verify it is indeed him:

  1. Use OAUTH, once that's done the account is now activated, along with all the messages, roles, and servers that meta account might be on.
  2. Use a Keybase like verification method, where we provide a key that the user most input somewhere, if the keys the match, the user can then claim the account