Chrome plugin development: user:pass@url not supported by Google Chrome anymore?

孤街浪徒 提交于 2019-12-10 22:07:25

问题


I develop a Chrome plugin that uses XMLHttpRequest to send a GET HTTP request with an username/password to a basic-auth-protected URL, so that it can then "auto-login" to it afterwards (since Chrome caches credentials for HTTP basic-auth).

Here's the code I use:

  var xml = new XMLHttpRequest();
  xml.open('GET',<url>,false,<username>,<password>)
  xml.send('');

It used to work fine for quite a while, but started failing some time ago. The plugin code hasn't changed, so I thought it could have to do with Chrome itself. I downloaded a previous version for OSX (17) and BAM, it worked again.

After some additional research, I found out that it might have to do with Chrome 19 not supporting the username:pwd@url syntax for authenticating to basic-auth protected URLs, because when I send the XMLHttpRequest, I see this in Google Chrome's js console:

GET http://user:pass@domain.com 401 (Unauthorized)

Does anyone know whether it's a bug or if Chrome stopped supporting this feature?

Thanks,

Marcelo.


回答1:


You are not the only person having this issue. It's ruffled several other people's feathers.

However, given the comments from the Chromium Developers:

The support for embedded auth in URLs was intentionally deprecated.

It looks like it was removed intentionally.



来源:https://stackoverflow.com/questions/10725654/chrome-plugin-development-userpassurl-not-supported-by-google-chrome-anymore

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