Any way to limit access to CouchDB view when JSONP is enabled?

我是研究僧i 提交于 2019-12-06 03:45:45

问题


I enabled JSONP on my iriscouch CouchDB so I could make ajax requests to my views. This means that anybody can make ajax request to my CouchDB views.

Is there any way to prevent this?

If not, then is there a way to limit access to the views (with JSONP turned off) so that only my application can view it (using a proxy)?


回答1:


Cross-domain functionality is still difficult. I do not think JSONP allows authenticated requests, therefore your choice with JSONP is between totally public data and totally private data.

(Incidentally, if you are concerned about privacy, note that your enemies or script kiddies or whoever can simply read the page source and query your views with curl.)

The correct solution to cross-domain security is Cross-Object Resource Sharing (CORS). There is a CouchDB CORS patch. Incidentally, Iris Couch (where I work) does unofficially support this patch and will activate it if you contact them.

If you use a proxy, the benefit is that you have huge flexibility and control about security. (The downside, obviously, is that now you must maintain a new server, and you must also be vigilant that somebody poked a hole in your security policy that you'd not realized.)



来源:https://stackoverflow.com/questions/6688839/any-way-to-limit-access-to-couchdb-view-when-jsonp-is-enabled

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!