Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
984 views
in Technique[技术] by (71.8m points)

authentication - Passing basic auth credentials in Google Chrome shows the pop again

I am using watir(Ruby selenium package) to try and login to url using basic auth

I pass the credentials like so

 https://username:password@nagios.com

However when the browser opens, i get a popup to enter the credentials again.

The code that i use is as follows

driver = Watir::Browser.new :chrome
driver.goto "https://username:password@nagios.com"

The above code opens the browser -> goes to the url but give the popup to enter the credentials again.

How do i login to the url using basic auth?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Turns out that Chrome has stopped supporting passing credentials in the url after version 52. more info https://medium.com/@lmakarov/say-goodbye-to-urls-with-embedded-credentials-b051f6c7b6a3

To fix this you need to set an argument --disable-blink-features="BlockCredentialedSubresources" while launching the browser. what this does is that it disable that feature

More info Bypass blocking of subresource requests whose URLs contain embedded credentials

This is my final code which works

 args = ['--disable-software-rasterizer',
                    '--disable-blink-features="BlockCredentialedSubresources"',
                    '--no-proxy-server',
                    '--disable-gpu',
                    '--no-sandbox',
                    '--ignore-certificate-errors']
driver = Watir::Browser.new :chrome, options: {args: args}
driver.goto "https://username:password@nagios.com"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...