Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArangoDB authentication via HTTP

I've seen examples of how to authenticate with a database using arangosh, but I couldn't find anything in the documentation about how to authenticate via the http API. Is this possible? Is it something like this:

http://username:[email protected]:8529/_api/document

like image 405
skinneejoe Avatar asked Jan 30 '14 17:01

skinneejoe


People also ask

How do I access ArangoDB?

You can access it in your browser at http://localhost:8529 - if not, please see Troubleshooting. By default, authentication is enabled. The default user is root .

How does ArangoDB store data?

ArangoDB stores documents in collections. The collection data is persisted on disk so it does not get lost in case of a server restart.

What is Arangosh?

The ArangoDB shell (arangosh) is a command-line client tool that can be used for administration of ArangoDB servers.


3 Answers

From the command line, you can do something like this to pass HTTP basic authentication to the server:

curl --basic --user "username:passwd" -X GET http://arangouri.com:8529/_api/document/...

The above example is for curl. If you use any other HTTP client, you have to find the options for setting the username / password for HTTP basic authentication and send them to the server.

like image 138
stj Avatar answered Oct 21 '22 11:10

stj


Ok, after playing around with authentication in Arango DB on Windows here is what I have found:

I could not get this command to work (which is supposed to enable authentication)

--server.disable-authentication false

UPDATE: I realized I couldn't get this command working because it's not a command at all :-o After looking more closely at the documentation it's a command line option. It should be used when you start arangosh. See documentation here.

I assume I need to adapt it somehow to work in a windows command prompt, but I'm not sure what needs to change. As a work around I opened the file "arangod.conf" (I found it here C:\Program Files (x86)\ArangoDB 1.4.7\etc\arangodb) and changed the following line:

disable-authentication = yes

to

disable-authentication = no

This enabled authentication when I restarted Arango. Yay!

Now to authenticate via http... very simple. It's just basic HTTP auth. So in my case I was using NodeJS and the request library to authenticate. Both examples below work fine.

Credentials appended with .auth:

request({
    url:'http://localhost:8529/_api/document/example/20214484',
    json: true
}, function (err, data){
    console.log(err);
    if (data.body.error) console.log("ERROR: " + data.body.errorMessage);

    console.log(data.body);
}).auth("username", "password");

OR with credentials in url:

request({
    url:'http://username:password@localhost:8529/_api/document/example/20214484',
    json: true
}, function (err, data){
    console.log(err);
    if (data.body.error) console.log("ERROR: " + data.body.errorMessage);

    console.log(data.body);
});
like image 43
skinneejoe Avatar answered Oct 21 '22 11:10

skinneejoe


It's done through Authorization header where you set authentication mechanism (e.g. Basic) followed by base64 encoded string in format [username]:[password]. More information can be found for example here.

like image 23
yojimbo87 Avatar answered Oct 21 '22 12:10

yojimbo87