couchdb自定义身份验证处理程

sap*_*n99 6 couchdb node.js

我不得不承认我对这个话题还不熟悉,特别是对erlang的新手.目前,我正在尝试使用各种身份验证处理程序 - 目标是在facebook,twitter等上进行"委托身份验证".

  1. 据我所知,couchdb的oAuth实现与我需要的完全相反.您可以使用它为沙发用户创建令牌,但不能接受Twitter accessTokens/secrets并将其映射到沙发用户.
  2. 我在datacouch中找到了我需要的东西 - 使用nodejs对twitter进行身份验证,然后从私人沙发中获取明文密码并使用_session-API创建沙发cookie.

现在我试图避免存储明文密码.我听说过使用proxy_authentification_handler,但看起来我要么太缺乏经验,要么使用它太愚蠢.我在couch_httpd_auth中做了(据我所知)正确的条目

couch_httpd_auth    auth_cache_size         50
                    authentication_db       _users
                    authentication_redirect /_utils/session.html
                    require_valid_user      false
                    proxy_use_secret        false
                    secret                  xxxxxxxxxxxx
                    timeout                 43200 
                    x_auth_roles            roles
                    x_auth_token            token
                    x_auth_username         uname
Run Code Online (Sandbox Code Playgroud)

以及httpd中的部分

httpd               allow_jsonp             true
                    authentication_handlers {couch_httpd_auth, proxy_authentification_handler},{couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}
                    bind_address            127.0.0.1
                    default_handler         {couch_httpd_db, handle_request} 
                    port                    5984
                    secure_rewrites         false
                    vhost_global_handlers   _utils, _uuids, _session, _oauth, _users
Run Code Online (Sandbox Code Playgroud)

正如文档中的注释中所提到的,我将proxy_use_secret设置为false(对于第一步)以允许在没有访问令牌的情况下进行身份验证.

当我现在在http:// localhost:5984/_utils/config.html?uname = user1&roles = user上进行GET时似乎不会影响任何事情......

谁有人跑过这个东西?我错过了什么吗?或者是否有机会在不编码erlang的情况下实现自定义身份验证处理程序?

非常感谢你的帮助

stw*_*sel 2

URL 参数没有执行任何操作。当您查看原始错误时,您会发现用户名和角色不是通过 URL 而是通过 HTTP 标头传递:

  • X-Auth-CouchDB-UserName :用户名,(couch_httpd_auth 部分中的 x_auth_username)
  • X-Auth-CouchDB-Roles :用户角色,以逗号分隔的角色列表(couch_httpd_auth 部分中的 x_auth_roles)
  • X-Auth-CouchDB-Token :用于验证授权的令牌(couch_httpd_auth 部分中的 x_auth_token)。该令牌是根据密钥和用户名创建的 hmac-sha1。客户端和 couchdb 节点中的密钥应该相同。密钥是 ini 的 couch_httpd_auth 部分中的密钥。如果未定义密钥,则此令牌是可选的。

一旦您提供了这些标头信息,身份验证实际上就会像宣传的那样进行。