【问题标题】:Sending credentials in url is not supported in chrome 59chrome 59 不支持在 url 中发送凭据
【发布时间】:2019-02-04 18:28:36
【问题描述】:

我对 SSRS 报表服务器进行了基本身份验证,以避免在从 Web 服务器访问 SSRS 报表服务器时出现登录弹出窗口。我在 url 本身中发送凭据。它可以在 google chrome 58 上运行,但现在它已更新到 chrome 59。现在我无法在浏览器 url 中发送凭据。

例如https://gooduser:secretpassword@www.example.co

用户名:好用户 密码:secredpassword

请帮忙解决这个问题!

【问题讨论】:

  • 简而言之:谷歌打破了它,似乎不想修复它。可能以“提高安全性”或类似的借口为借口。有没有地方可以游说消除这种精神错乱?

标签: google-chrome authentication reporting-services


【解决方案1】:

我用 chrome 扩展解决了同样的问题。

在扩展 background.js 中

chrome.extension.onMessage.addListener(  function(request, sender, sendResponse){
   chrome.webRequest.onAuthRequired.addListener(
        function(details, callbackFn) {
            console.log("onAuthRequired!", details, callbackFn);
            callbackFn({
                authCredentials: {username: request.username, password: request.password }
            });
        },
        {urls:  request.url + "/*"]},
        ['asyncBlocking']
    );
});

在扩展 contentscript.js 中

window.addEventListener("message", function(event) {
  if ( event.type == "BASIC_AUTH" ) {
    chrome.runtime.sendMessage(  
            event.data, 
            event.data.sender, 
            function (response) {}       
        ); 
  }
}); 

在 HTML javascript 中

window.postMessage({ type: "BASIC_AUTH", url:"www.mydomain.com", username:"myusername", password:"mypassword" }, "*");

如果您喜欢使用 Chrome 网上应用店的扩展程序,例如:MultiPass for HTTP basic authentication

【讨论】:

    【解决方案2】:

    您可以使用“MultiPass for HTTP basic authentication”Chrome 扩展来处理这个问题。

    你可以通过 GitHub MultiPass for HTTP basic authentication

    (或)

    从 Chrome 网上应用店下载扩展程序 - MultiPass Chrome Extension

    (或)

    将扩展下载为 crx。您可以从chrome-extension-downloader获取它作为crx

    一旦您将扩展下载为 crx 文件 - 将其配置到您的测试/源中非常简单。

    这可以使用Sample Basic Auth-Site 进行测试。

    public class ChromeAuthTest {
    
        WebDriver driver;
    
        public ChromeAuthTest() {
            System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
        }
    
        private void initDriver() {
            ChromeOptions cOptions = new ChromeOptions();
            cOptions.addExtensions(new File("MultiPass-for-HTTP-basic-authentication_v.crx"));
            driver = new ChromeDriver(cOptions);
            configureAuth(
                    "https://the-internet.herokuapp.com/basic_auth",
                    "admin",
                    "admin");
        }
    
        private void configureAuth(String url, String username, String password) {
            driver.get("chrome-extension://enhldmjbphoeibbpdhmjkchohnidgnah/options.html");
            driver.findElement(By.id("url")).sendKeys(url);
            driver.findElement(By.id("username")).sendKeys(username);
            driver.findElement(By.id("password")).sendKeys(password);
            driver.findElement(By.className("credential-form-submit")).click();
        }
    
        public void doTest() {
            initDriver();
            driver.get("https://the-internet.herokuapp.com/basic_auth");
            System.out.println(driver.getTitle());
            driver.quit();
        }
    
        public static void main(String[] args) {
            new ChromeAuthTest().doTest();
        }
    }
    

    注意:本文摘自Answer

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-06
      • 1970-01-01
      • 1970-01-01
      • 2019-08-02
      • 1970-01-01
      • 2017-11-21
      • 2012-05-30
      相关资源
      最近更新 更多