Error creating user in CouchDB 1.0

后端 未结 4 614
执笔经年
执笔经年 2021-02-10 08:13

My system is ubuntu 10.04 and I have CouchDB 1.0 installed. I can create admin, or more admins, log in as admin and everything works fine.

Since 0.11 in CouchDB there i

相关标签:
4条回答
  • 2021-02-10 08:55

    To create a user, PUT a JSON document to http://localhost:5984/_users/org.couchdb.user:<username>

    For example create a file login.json like this:

    {
        "_id": "org.couchdb.user:test",
        "name": "test",
        "password_sha": "24e8e07c23d8ae85108468ec4814b2f0fa84edde",
        "salt": "78f67e252351a56d6e1e6df9ba005239",
        "roles": [],
        "type": "user"
    }
    

    Then PUT the data into couchdb:

    curl -X PUT http://<admin>:<password>@localhost:5984/_users/org.couchdb.user%3Atest -S -s -H "Content-Type: application/json" -d @login.json
    

    (Replace <admin> and <password> with your couchdb credentials.)

    Now you should be able to log into couchdb with the user "test" and the password "test123".

    0 讨论(0)
  • 2021-02-10 09:04

    I had a similar error on debian. I compiled CouchDB from the build-couchdb repo. I could create admin users but not regular users. I was also not able to run temporary views. Solved it by purging libmozjs1d and erlang-nox and recompiling. hope that helps.

    0 讨论(0)
  • 2021-02-10 09:06

    Ran into this issue myself and found that it was due to the fact that my name and the name portion of the _id string did not match:

    curl -X PUT https://admin:password@server:6984/_users/org.couchdb.user:dan \
        -H "Accept: application/json" \
        -H "Content-Type: application/json" \
        -d '{"name": "Dan", "password": "password", "roles": [], "type": "user"}'
    

    this does not work because the name portion of the _id dan from org.couchdb.user:dan does not match the name supplied Dan.

    The following works because the username matches (now both Dan)

    curl -X PUT https://admin:password@server:6984/_users/org.couchdb.user:Dan \
        -H "Accept: application/json" \
        -H "Content-Type: application/json" \
        -d '{"name": "Dan", "password": "password", "roles": [], "type": "user"}'
    
    0 讨论(0)
  • 2021-02-10 09:06

    It looks like you already have an admin account on the system, which CouchDB is detecting and expecting you to be logged in as to create accounts. Check your local.ini config file to see if you have any admins defined in the [admins] section - you will probably have some defined if you are upgrading from an old install.

    Log in as one of those admins, or change their password if you don't remember it (just replace the has with your clear text password and it'll be hashed the next time CouchDB starts). Now restart CouchDB. If you had an admin account, then log in as that user, or if you removed all of the old accounts, then click sign up to create a new one.

    Cheers.

    0 讨论(0)
提交回复
热议问题