CouchDB 代理身份验证安全 - 用户角色混淆

CouchDB Proxy Authentication security - user roles confusion

用户身份验证成功后,我的身份验证服务器会生成一个令牌并将其传递给客户端。

文档说客户端必须添加以下内容 headers:

X-Auth-CouchDB-UserName: username;
X-Auth-CouchDB-Roles:comma-separated (,) list of user roles;
X-Auth-CouchDB-Token: authentication token.

这是否意味着客户端在每个请求中都定义了自己的角色?为什么他不能将 'admin' 添加到角色列表中?

客户端是使用服务器资源或从服务器请求资源的任何东西。

"The client" 在这种情况下是您的 proxy/auth 服务器,而不是网络浏览器。 (文档可能需要澄清一下。)

所以是的,您的 proxy/auth 服务器,即 CouchDB 的客户端,应该适当地设置 header。

推而广之,它还应该通过从客户端收到的任何X-Auth-Couchheaders (大概是网络浏览器)。

好观察。使用 JWT Authentication 似乎可以弥补这个漏洞,因为我的理解是整个令牌是 signed-over.

也就是说,无论哪种情况都无法避免:

  • 必须完全信任持有秘密的实体
  • 必须小心防止其泄漏 headers

前者是不可避免的,因为这些插件的目的是委托身份验证。您要么信任代理(或 JWT 发行者),要么让这些 authentication_handlers 禁用。

后者是例如OAuth 1 hardened itself somewhat against, in that ± the entire request was signed over and one couldn't simply take a couple auth headers from an earlier leaked request and slap them on a new forged request. Nonce and timestamp fields were supposed to be checked to avoid verbatim replays of prior requests as well. (All this was dropped in OAuth 2 for whatever that's worth… and even OAuth 1 had some notable loopholes 在实践中……)

因此在实践中,应谨慎使用 Proxy 或 JWT 身份验证处理程序。假设在您的 CouchDB 和身份验证源周围都设置了某种“防火墙”,那么正如@Flimzy 的回答提到的那样,可以防止意外的 headers 从该边界外进入内部——以及保持真正的 headers 从向外泄漏 - 应该可以减轻大多数潜在的滥用。