使用CouchDB PouchDB阻止身份验证弹出窗口401 [英] Prevent Authentication popup 401 with CouchDB PouchDB

查看:152
本文介绍了使用CouchDB PouchDB阻止身份验证弹出窗口401的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于JavaScript Web应用程序(基于AngularJS),我正在使用PouchDB在服务器上复制CouchDB数据库. PouchDB中的身份验证与 pouchdb身份验证很好地配合.我想通过html/js登录屏幕进行管理.

For a JavaScript web app (AngularJS based) I am using PouchDB replicating a CouchDB database on my server. Authentication in PouchDB works nicely with pouchdb-authentication. I want to manage this through a html/js login screen.

但是,如果用户输入了错误的凭据,我会从CouchDB服务器收到401 Unauthorized,这会导致浏览器弹出请求凭据.

However, if the user enters wrong credentials, I receive a 401 Unauthorized from the CouchDB server that causes a browser popup asking for credentials.

如何防止此丑陋的身份验证弹出窗口,而仅处理JavaScript中的所有内容?!

How can I prevent this ugly Authentication popup and just handle everything from my javascript?!

推荐答案

我终于找到了解决方案:

I finally found the solution:

编辑CouchDB配置local.ini并更改作为响应发送的HTTP标头:

Edit the CouchDB config local.ini and change the HTTP Header sent in response:

WWW-Authenticate = Other realm="app"

最初是

WWW-Authenticate = Basic realm="administrator"

或者如果有评论,那就是发送出去的东西. WWW-Authenticate = Basic显然使浏览器通过显示其模式来处理(失败的)身份验证.将Basic更改为其他任何内容都会使浏览器忽略它,您可以自己处理登录.

or if it is commented, that's what is sent out anyway. The WWW-Authenticate = Basic apparently causes the browser to handle (failed) authentication by showing its modal. Changing Basic to anything else makes the browser ignore it and you can deal with the login yourself.

这篇关于使用CouchDB PouchDB阻止身份验证弹出窗口401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆