Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCUMENTATION - Creating a new user method HTTP method is wrong #4642

Closed
dbeniteza opened this issue Jun 15, 2023 · 1 comment · Fixed by #4645
Closed

DOCUMENTATION - Creating a new user method HTTP method is wrong #4642

dbeniteza opened this issue Jun 15, 2023 · 1 comment · Fixed by #4645

Comments

@dbeniteza
Copy link

Hello,

I've found an error on the documentation section 1.5.2.2. Creating a New User.

It is said "Creating a new user is a very trivial operation. You just need to do a PUT request with the user’s data to CouchDB"

This is wrong, since the PUT method will try to create the _users database. The correct HTTP method is POST.

Please correct this typo in the documentation.

As a suggestion, it would help to explicitly include in this documentation section that this call must be done with an admin user. Consider including in the curl example something like this:

curl -X **POST** <admin_user>:<admin_password>@localhost:5984/_users/org.couchdb.user:jan \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -d '{"name": "jan", "password": "apple", "roles": [], "type": "user"}'
@nickva
Copy link
Contributor

nickva commented Jun 15, 2023

since the PUT method will try to create the _users database. The correct HTTP method is POST.

PUT should not create a new database but a new user document

The URL is https://localhost:5984/_users/org.couchdb.user:jan _users is the database and org.couchdb.user:jan is the document ID. PUT is also the correct method in this case as we're creating or replacing a resource and we're identifying it by its resource URL path.

Maybe we should assert or include that we are assuming in the documentation that _users db has already been created and the jan user has not been added to it yet.

Good point however that this needs an admin user and admin password. That is mentioned above in Authentication Database but that may be easy to miss so showing it in the example would make it easier to see.

jiahuili430 added a commit to jiahuili430/couchdb that referenced this issue Jun 18, 2023
jiahuili430 added a commit to jiahuili430/couchdb that referenced this issue Jun 18, 2023
nickva pushed a commit that referenced this issue Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants