问题描述
我正在调用以下代码:
$.couch.login($.extend({ name: "harry", password: "secrets"}, callback));
$.couch.session(callback);
其中harry只是我使用 $。couch创建的虚拟用户.signup
和回调
是一个简单的对象,用于指定成功/错误/完整函数,具体如下:
where "harry" is just a dummy user I created using $.couch.signup
and callback
is a simple object specifying success/error/complete functions with bodies like these:
success: function (data) {
console.log('Success');
console.log(data);
}
此代码返回以下内容:
Success
Object {ok: true, name: "harry", roles: Array[0]}
Success
Object {ok: true, userCtx: Object, info: Object}
第一次回报没问题,但第二个,来自 session
的那个, userCtx
对象基本上是空的,带有 null
name。
The first return is fine, but the second, the one from session
, the userCtx
object is basically empty, with a null
name.
此外,当我尝试使用我的个人用户名和密码(我用作被褥管理员的用户名)登录时,这个返回:
Also, when I try to login using my personal username and password (the ones I use as a Futon admin), this is returned:
Success
Object {ok: true, name: null, roles: Array[1]}
(0: "_admin")
Success
Object {ok: true, userCtx: Object, info: Object}
令人着迷的是,第一个请求知道似乎知道我是管理员,但没有得到任何其他数据,第二个请求做同样的事情上一个例子。
and fascinatingly, the first request knows seems to know I'm an admin, but doesn't get any other data, and the second request does the same thing as the previous example.
有什么想法吗?我没有正确使用 $。couch.session
吗?我的沙发实例有问题吗?
Any thoughts? Am I not using $.couch.session
correctly? Is there something wrong with my couch instance?
仅供参考我使用的是1.4.0版并且是从源代码构建的。
FYI I am using version 1.4.0 and built from source.
推荐答案
事实证明我真正需要的是一个。沙发实例无法访问 AuthSession
cookie,因为它来自端口 5984
。现在情况很好,以下添加到我的 apache2.conf
(某些人可能是 httpd.conf
)
It turns out all I really needed was an apache reverse proxy. The couch instance didn't have access to the AuthSession
cookie, since it was coming from port 5984
. Now things work great with the following added to my apache2.conf
(may be httpd.conf
for some)
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
ProxyPass /_couch http://localhost:5984 nocanon
ProxyPassReverse /_couch http://localhost:5984
这篇关于$ .couch.session返回具有空名称的userctx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!