CouchDB使用AngularJS登录:auth cookie仅为/ _session发送 [英] CouchDB sign-in with AngularJS: auth cookie sent for /_session only
问题描述
上一篇文章 -
在学习Angular和CouchDB时,我遇到了死锁。
我做错了什么?我不想隐藏couchdb背后的东西与自定义auth - 太复杂,不是一个好的方法,我想。
UPD:获取 Cookie
头也失败 - 它不能在中使用HttpPromise.success(function(data,status,headers,config))
headers
。我试图得到它像 headers(Set-Cookie)
- 没有运气。
在couchdb配置中可能出现错误?我已将其上传到pastebin 。
- 检查CORS是否启用(
* $ c $ c>在我的原因)
- 在配置中检查
cors / credentials
li>在$ http
中使用 - Check CORS to be enabled (
*
in my cause) - Check
cors/credentials
in config, it must be true - Use
{withCredentials:true}
in Angular$http
{withCredentials:true}
现在它工作。
What I have now: AngularJS app with two controllers. First works with CouchDB documents and the second perform sign-in requests to example.com/demo/_session
.
When I open application, I can't do editing with couchdb (in first controller), because some actions I've limited to logged users only. In second controller I'm sending simple POST over $http
, which return Http-only
(so no cookie magic there) auth cookie AuthSession
. That cookie bound to couchdb address and in theory any request from page to couchdb address must contain that cookie also.
But this no happens. No one call to couchdb, except calls to /_session
comes with AuthSession
cookie. E.g. example.com/demo/_session
getting with AuthSession
and example.com/demo/records
not.
In learning Angular and CouchDB I came to deadlock.
What I'm doing wrong? I do not want to hide couchdb behind something with custom auth — too complex and not a good way, I think.
UPD: Getting Set-Cookie
header also fails — it not available in HttpPromise.success(function (data, status, headers, config))
headers
. I'm tried to get it like headers("Set-Cookie")
— no luck.
Maybe something wrong in couchdb configuration? I've uploaded it to pastebin.
Now it works.
这篇关于CouchDB使用AngularJS登录:auth cookie仅为/ _session发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!