angularjs – Internet Explorer 11替换授权头

前端之家收集整理的这篇文章主要介绍了angularjs – Internet Explorer 11替换授权头前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
什么会导致Internet Explorer替换HTTP标头

授权:承载<服务器提供令牌>

授权:协商<某个令牌>

在提出AJAX请求时?

细节

在Internet Explorer中,配置为包含头部授权:承载的一些AJAX请求正由Internet Explorer发送,标题为Authorization:Negotiate …。

例如,Fiddler显示三个请求中的前两个包含Authorization:Bearer …头,而第三个请求突然包含Authorization:Negotiate …头。前两个请求成功,第三个请求失败,因为请求无法正确认证。

所有请求都使用相同的客户端代码构建,并且一个接一个地(在一秒钟内)。我已经验证了授权头在所有三种情况下都正确地包含承载令牌,直到请求被提供给浏览器为止。

此外,我在Chrome中看不到同样的行为;它只发生在IE中。

要求1

GET http://localhost/myapp/api/User HTTP/1.1
Accept: application/json,text/plain,*/*
Authorization: Bearer oEXS5IBu9huepzW6jfh-POMA18AUA8yWZsPfBPZuFf_JJxq-DKIt0JDyPXSiGpmV_cpT8FlL3D1DN-Tv5ZbT73MTuBOd5y75-bsx9fZvOeJgg04JcO0cUajdCH2h5QlMP8TNwgTpHg-TR9FxyPk3Kw6bQ6tQCOkOwIG_FmEJpP89yrOsoYJoCfrAoZ7M4PVcik9F9qtPgXmWwXB2eHDtkls44wITF_yM_rPm5C47OPCvMVTPz30KwoEPi6fHUcL3qHauP-v9uypv2e48TyPHUwLYmNFxyafMhBx4TkovnRcsdLHZiHmSjMq0V9a2Vw70
Referer: http://localhost/client/login.html
Accept-Language: en-US
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost
DNT: 1
Connection: Keep-Alive

请求2

POST http://localhost/myapp/api/Permissions HTTP/1.1
Referer: http://localhost/client/#/Dashboard
Content-Type: application/json
Authorization: Bearer oEXS5IBu9huepzW6jfh-POMA18AUA8yWZsPfBPZuFf_JJxq-DKIt0JDyPXSiGpmV_cpT8FlL3D1DN-Tv5ZbT73MTuBOd5y75-bsx9fZvOeJgg04JcO0cUajdCH2h5QlMP8TNwgTpHg-TR9FxyPk3Kw6bQ6tQCOkOwIG_FmEJpP89yrOsoYJoCfrAoZ7M4PVcik9F9qtPgXmWwXB2eHDtkls44wITF_yM_rPm5C47OPCvMVTPz30KwoEPi6fHUcL3qHauP-v9uypv2e48TyPHUwLYmNFxyafMhBx4TkovnRcsdLHZiHmSjMq0V9a2Vw70
Accept: application/json,*/*
Accept-Language: en-US
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost
Content-Length: 1419
DNT: 1
Connection: Keep-Alive
Pragma: no-cache

<Post Data Removed>

请求3

GET http://localhost/myapp/api/UserPreferences/Dashboard HTTP/1.1
Referer: http://localhost/client/#/Dashboard
Content-Type: application/json
Authorization: Negotiate YHsGBisGAQUFAqBxMG+gMDAuBgorBgEEAYI3AgIKBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKKwYBBAGCNwICHqI7BDlOVExNU1NQAAEAAACXsgjiBgAGADMAAAALAAsAKAAAAAYBsR0AAAAPVk1ERVZFTlYtU1JTQ0VSSVM=
Accept: application/json,deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Connection: Keep-Alive
DNT: 1
Host: localhost

这些请求是通过AngularJS $ http服务进行的,后端是在IIS中托管的ASP.NET Web API。

我们遇到Internet Explorer正在缓存凭据的问题。我们可以使用以下脚本解决问题:
document.execCommand('ClearAuthenticationCache','false');

见:Wikipedia

原文链接:https://www.f2er.com/angularjs/144835.html

猜你在找的Angularjs相关文章