ArangoDB Authentication and Databases
I am using the HTTP API for ArangoDB 2.6 (but I believe I ran into a problem that I am going to describe in previous versions as well).
- I am authenticating with ArangoDB using / passwd user (root or existing user).
- I am creating a new database with the same user / passwd.
- When I try to access the newly created database using the same user / passwd, I get 401 (unauthorized).
When I try to use the web control panel, I instead run into a similar problem where I am thrown back to the login screen and can no longer log in when I try to access the database page. Am I doing something wrong? Could this be a mistake? Thanks in advance.
source to share
The following seems to work in 2.6 with authentication enabled. It uses the HTTP REST API with curl
:
First of all, we need to check that we can actually connect to the _system database with a privileged user. We need this to create a new database:
curl --dump - --basic --user "root:rootpasswd" -X GET \
http://127.0.0.1:8529/_db/_system/_api/version && echo
This should return HTTP 200. Now that we can connect to the _system database, we can issue a call to create a new database called "testdb". We will create a user named "testuser" and a password "test1234" to connect to:
curl --dump - --basic --user "root:rootpasswd" -X POST \
http://127.0.0.1:8529/_db/_system/_api/database \
--data '{"name":"testdb","users":[{"username":"testuser","passwd":"test1234"}]}' && echo
This should have returned HTTP 201.
Now we can finally check that we can actually connect to the newly created database with the new user:
curl --dump - --basic --user "testuser:test1234" -X GET \
http://127.0.0.1:8529/_db/testdb/_api/version && echo
This should also return HTTP 200, which means you can connect to the newly created database with the new user.
Check if this works for you too.
source to share