Joohwan
Joohwan

Reputation: 2512

ArangoDB authentication and databases

I am using the HTTP API for ArangoDB 2.6 (but I believe I encountered the problem I am about to describe in previous versions as well).

  1. I authenticate with ArangoDB with user/passwd (root or an existing user).
  2. I create a new database with the same user/passwd.
  3. When I try to access the newly created database with the same user/passwd, I get a 401 (Unauthorized).

When I try to use the web dashboard instead I run into a similar problem where I get kicked back to the login screen and can't log in anymore when I try to access a database page. Am I doing something wrong? Could this be a bug? Thanks in advance.

Upvotes: 3

Views: 1637

Answers (1)

stj
stj

Reputation: 9097

The following seems to work in 2.6 with authentication turned on. It uses the HTTP REST API with curl:

First of all, we need to verify that we can actually connect to the _system database with a privileged user. We need this in order 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 an HTTP 200. Now that we can connect to the _system database, we can issue a call to create a new database, named "testdb". We'll create a user named "testuser" and password "test1234" to connect to it:

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 an HTTP 201.

Now we can finally check that we can actually connect to the just 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 return HTTP 200 as well, meaning that you can connect to the just created database with the new user.

Please check whether this works for you, too.

Upvotes: 5

Related Questions