通过HTTP进行ArangoDB身份验证 [英] ArangoDB authentication via HTTP

查看:421
本文介绍了通过HTTP进行ArangoDB身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过如何使用arangosh对数据库进行身份验证的示例,但我在文档中找不到有关如何通过http API进行身份验证的内容。这可能吗?它是这样的:

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://用户名:passwd@arangouri.com:8529 / _api / document

推荐答案

好的,在Arango中玩认证后Windows上的数据库是我发现的:

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

更新:我意识到我无法使用此命令,因为它根本不是命令:-o在仔细查看文档后,它是一个命令行选项。它应该在你开始arangosh时使用。请参见文档

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.

我假设我需要以某种方式调整它以在Windows命令提示符下工作,但我不确定需要更改什么。作为一个解决方法我打开文件arangod.conf(我在这里找到它C:\Program Files(x86)\ ArangoDB 1.4.7 \ etcc \ rangodb)并更改了以下行:

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

当我重新启动Arango时启用了身份验证。 Yay!

This enabled authentication when I restarted Arango. Yay!

现在通过http验证...非常简单。它只是基本的HTTP身份验证。所以在我的情况下,我使用NodeJS和请求库进行身份验证。以下两个示例都可以正常工作。

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.

附加.auth的凭证:

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");

或凭网址中的凭据:

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);
});

这篇关于通过HTTP进行ArangoDB身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆