couchdb - CouchDB 无法获取非管理员用户的 cookie 身份验证会话
问题描述
对于管理员用户:
$ curl -X POST localhost:5984/_session -d "username=admin&password=admin"
{"ok":true,"name":"admin","roles":["_admin"]}
$ curl -vX GET localhost:5984/_session --cookie AuthSession=YWRtaW...
{"ok":true,"userCtx":{"name":"admin","roles":["_admin"]},"info":{"authentication_db":"_users","authentication_handlers":["cookie","default"],"authenticated":"cookie"}}
但对于普通用户:
$ curl -vX POST localhost:5984/_session -d "username=user&password=123"
{"ok":true,"name":"user","roles":["users"]}
$ curl -vX GET localhost:5984/_session --cookie AuthSession=ZGlqbzo...
{"ok":true,"userCtx":{"name":null,"roles":[]},"info":{"authentication_db":"_users","authentication_handlers":["cookie","default"]}}
当我通过 iron-ajax 元素或简单地从 chrome 执行 XmlHttpRequest 时,也会发生同样的事情。我究竟做错了什么?
CouchDB 版本:2.1.1
配置:
[chttpd]
bind_address = 0.0.0.0
port = 5984
authentication_handlers = {couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}
[httpd]
enable_cors = true
[couch_httpd_auth]
allow_persistent_cookies = true
timeout = 60000
[cors]
credentials = true
origins = *
headers = accept, authorization, content-type, origin, referer
methods = GET, PUT, POST, HEAD, DELETE
解决方案
当我从我的 local.ini 中删除时问题消失了
authentication_handlers = {couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}
因为我使用了不正确的处理程序:couch_httpd_auth
在配置中chttpd
,当该处理程序仅被编写为与原始couch_httpd
模块一起使用时
推荐阅读
- java - MongoDB + HibernateOGM + Spring Boot 自动创建数据库
- audio - SIM800C : 上传的音频 AMR 文件在通话过程中播放时有噪音
- python - 如何使用 SQL Alchemy 在 DB 表中维护唯一的字母数字序列?
- javascript - 如何用js实现talib的LINEARREG_SLOPE函数?
- java - Android WorkManager - 手机充满电时运行任务
- python - 在汇源图中找到最小加权匹配
- algorithm - 来自未知长度的流的均匀分布的样本
- e2e-testing - 赛普拉斯:如何知道元素在使用 If 条件时是否可见?
- android - 如何以编程方式拒绝Android版本9中的呼叫.....????/
- ios - 使用 ThemeData 作为 CupertinoApp 的主题