Search code examples
javascripthttphttp-authentication

Add active HTTP login to browser


Is it possible to add an "active login" (Firefox terminology for HTTP credentials) to a browser by using JavaScript? The JavaScript would simply give username and password to the browser. If it is possible: How?

The goal is to get rid of the popup a browser shows when it asks for HTTP credentials. It only shows the popup if it does not already know the credentials.

To do this, I'd like to show a HTML login form, let the user enter the credentials in it, and on submit pass them to the browser by executing some JS and then redirecting to the protected content.


Solution

  • You may try redirecting to a URL containing the username and password:

    http://user:password@host/path?query
    

    Note that due to various security restrictions, this may not always work, or generate security alerts.