2013-02-23 181 views
1

在couchdb中,如果数据库受到保护,它将根据“authentication_redirect”配置设置重定向到“/_utils/session.html”。Couchdb身份验证/授权

如果我有几个数据库,如DB1,DB2,等我要的是CouchDB的重定向到/db1/logon.html为DB1 & /db2/logon.html对于DB2,等等。

是它可能使couchdb根据正在访问的数据库重定向到特定的登录文件?

回答

1

我能想到做到这一点的唯一方法是使用像重写:

{from: '/db1/*', to: '../../../db1/*'}, 
{from: '/db2/*', to: '../../../db2/*'} 

在你的主数据库调用它主要从本地主机被服务:5984。

配置需要的是在蒲团

httpd secure_rewrites false 
vhosts localhost:5984 /main/_design/edit/_rewrite 

如下与此唯一的问题是,你将不得不把secure_rewrites关闭这可能会弄乱你的安全。

这是未经测试的,但应该是关闭。

7

您可以传递一个?fail =参数。告诉couchdb在哪里发送验证失败的用户。蒲团使用它是这样的;

成功认证;

curl -sv 'localhost:5984/_session?next=/foo&fail=/bar' -d 'name=foo&password=bar' 

< HTTP/1.1 302 Moved Temporarily 
< Location: http://localhost:5984/foo 
{"ok":true,"name":null,"roles":["_admin"]} 

失败的验证;

curl -Haccept:text/html -sv 'localhost:5984/_session?next=/foo&fail=/bar' -d 'name=foo&password=baz' 
< HTTP/1.1 302 Moved Temporarily 
< Location: http://localhost:5984/bar 
{"error":"unauthorized","reason":"Name or password is incorrect."}