Files
webextensions-examples/stored-credentials
Simeon Vincent 3d52dce7c8 Remove Chrome support
@rebloor [noted][1] that the root readme states that "examples are tested in Firefox." This change removes Chrome support in order to accurately reflect the framing established in the README.

[1]: https://github.com/mdn/webextensions-examples/pull/565#issuecomment-2241954087
2025-03-09 17:14:12 -07:00
..
2025-03-09 17:14:12 -07:00
2025-03-09 17:11:30 -07:00

stored-credentials

Although this add-on uses a stored password to authenticate to a web server, it should not be taken as an example of how to store or work securely with passwords. It's only a demonstration of how to use the webRequest.onAuthRequired API.

This add-on uses the webRequest.onAuthRequired API to log the user into the demo site at https://httpbin.org/basic-auth/user/passwd using a stored username and password.

This add-on stores a username and password using the storage.local API. The default value is the correct value for the demo site:

username: "user"
password: "passwd"

You can change the default values in the add-on's options page.

The add-on then uses webRequest.onAuthRequired to intercept authentication requests from the demo site. When it gets such a request, it fetches the stored credentials and supplies them asynchronously.

To try out the add-on: