18

Browsers rarely make it easy to log out of a site once you've logged on with HTTP Basic authentication. How can I do this?

(This form of authentication is rarely used on the public web, but the intranet I'm on uses it all the time. It's the one where you get a pop-up dialog asking you for a username and password.)

4 Answers4

22

For most browsers

Log in with a nonsense user using the address bar. For example, if you logged on to http://codereview.internal.company and loaded the URL http://codereview.internal.company/r144, enter this:

http://logout:logout@codereview.internal.company/r144

h/t Riyadi on tolaris.com

For Chrome

This used to worked on Chrome, but no longer. There might not be a complete solution, but see https://superuser.com/a/1598511/28585 and https://stackoverflow.com/a/64611309/327615 for some discussion.

9

For chrome browser you can restart the chrome application completely by typing in the address bar.

chrome://restart

Another way is that, always open the browser in incognito mode. For chrome the shortcut is

ctrl + shift + n

Another way you can try it out is that, try to give wrong credentials if you want to logout. Say,

randometxt@localhost:3000

*sometimes, this works.

1

From the answer

You have the following options on Chrome

  1. chrome://restart

  2. Launch in incognito mode

  3. Enter the wrong username in the url without the resources

    eg: if the url is http://mywebsite.com/resources/, it will not work if I enter http://wrong@mywebsite.com/resources/, but will work if I enter only http://wrong@mywebsite.com/

    1. it clears the Basic Auth credentials
    2. prompt for the credentials again
    3. However, entering the valid credentials will not work, as in the background, chrome still send the wrong user as part of the url, even though the url appears right in the address bar When prompted for credentials you would need to Cancel, and click the address bar and reload the page from pressing enter. Now enter the correct password
0

In Firefox, go to Preferences -> Privacy & Security -> Clear history, then select only "Active logins" checkbox, (optionally choose appropriate time period) and click "OK".

(This will log you out of all sites you are logged in with HTTP Basic auth. There's no official method to log out of one site only)

raj
  • 2,245