简体   繁体   English

Sencha Touch将基本身份验证注入所有请求

[英]Sencha Touch inject Basic Authentication into all requests

I have a Sencha Touch 2.3.1 app that, when inside a PhoneGap/Cordova container, uses Basic Authentication against an IIS server. 我有一个Sencha Touch 2.3.1应用程序,当它在PhoneGap / Cordova容器内时,对IIS服务器使用基本身份验证。

For some unknown reason, the app worked in old phonegap and cordova versions for some two or three years with only the first request containing a username and password, although every resource I find on the web states that this is not possible. 由于某些未知原因,该应用程序在旧的phonegap和cordova版本中工作了大约两三年,只有第一个请求包含用户名和密码,尽管我在网上找到的每个资源都说这是不可能的。

This behaviour has definitely changed after I upgraded to the most recent Cordova 6.4; 升级到最新的Cordova 6.4之后,这种行为肯定发生了变化。 now every request has to contain username and password. 现在每个请求都必须包含用户名和密码。

Is this an issue with the new version of cordova, or what other reason could there be? 这是新版cordova的问题,还是有其他原因? (Possibly the missing inappbrowser plugin? It was uninstalled when I upgraded to Cordova 6.4, and trying to install it yields Unpublished by ccreeves on 2015-10-11T04:52:47.498Z .) (可能是缺少的inappbrowser插件?当我升级到Cordova 6.4并且尝试安装它时,它被卸载了, Unpublished by ccreeves on 2015-10-11T04:52:47.498Z 。)

As far as I can see, state of the art would be to inject the username and password into all requests . 据我所知,最先进的技术是将用户名和密码注入所有请求中

Is there a way to globally set username and password for all requests in Sencha Touch, so I don't have to repeat it everywhere it my code? 有没有办法为Sencha Touch中的所有请求全局设置用户名和密码,所以我不必在我的代码的任何地方重复它? (I have like 50 Ext.Ajax.request plus around 50 stores, and all of them should only contain the username and password if inside cordova.) (我有50个Ext.Ajax.request加上大约50个商店,如果在cordova里面,所有这些应该只包含用户名和密码。)

Inject Basic Authentication into all Ajax requests ( Ext.Ajax.request as well as all proxy:Ajax CRUD operations): 将基本身份验证注入所有Ajax请求( Ext.Ajax.request以及所有proxy:Ajax CRUD操作):

Ext.Ajax.setDefaultHeaders({
    "Authorization": "Basic " +  btoa(username+":"+password)
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM