Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArangoDB authentication and databases

Tags:

arangodb

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.

like image 944
Joohwan Avatar asked Jul 29 '26 20:07

Joohwan


1 Answers

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.

like image 68
stj Avatar answered Aug 02 '26 01:08

stj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!