Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Dedicated admin API to create new users (and not update existing users) #8165

Open
damnms opened this issue Aug 25, 2020 · 2 comments
Open
Labels
A-Admin-API T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.

Comments

@damnms
Copy link

damnms commented Aug 25, 2020

Description:

i have a little application which can create new users on homeservers. it talks to the homeserver through the admin rest api and therefore requires a valid admin user.
now i noticed that those PUT requests are not only creating but also updating existing users.

https://restfulapi.net/rest-put-vs-post/

POST /device-management/devices : Create a new device

At the moment, only the second part is supported by matrix synapse:

PUT /device-management/devices/{id} : Update the device information identified by "id"

https://github.com/matrix-org/synapse/blob/master/docs/admin_api/user_admin_api.rst#create-or-modify-account

So i have to check if the user already exists and then create it. Its just a small thing but i would really appreciate it, if there is some kind of:

POST /_synapse/admin/v2/users/

with a body like:

{user: "someNewUser", password: "someNewPassword"}

which returns an Error when the user which should be created already exists.

I guess that is very common in the web that an exception is thrown when a user already exists instead of (accidentally) updating the password... thats what happened to my little project. Lucky me it is only in testing yet :)

@clokep clokep changed the title PUT vs POST to register new users Admin API to create new users (and not update existing users) Aug 25, 2020
@babolivier babolivier changed the title Admin API to create new users (and not update existing users) Dedicated admin API to create new users (and not update existing users) Aug 27, 2020
@babolivier babolivier added z-p2 (Deprecated Label) Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution labels Aug 27, 2020
@babolivier
Copy link
Contributor

This could also be done in a simpler way by adding an update property to the existing API (that would default to true) that updates the user if it already exists if true, and returns an error in this case if false.

Given our current load and priorities this isn't something we'll likely pick up soon, however if you (or anyone else stumbling upon this issue) want to take it on, we'd gladly welcome a PR 🙂

@awesome-manuel
Copy link
Contributor

POST normally let's the server generate the object ID (user ID in our case), but unless you create a guest account, you would want to set the user ID yourself.

@erikjohnston erikjohnston added T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. and removed Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p2 (Deprecated Label) labels Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Admin-API T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.
Projects
None yet
Development

No branches or pull requests

5 participants