Skip to content

[Feature] Support of multiple HTTP credentials for different origins #22013

Closed

Description

With feature #20464 it is possible to specify the origin of http credentials.

An idea of enhancement would be to allow providing multiple credentials for different origins.

For example if different username/password are needed on either server1.com or server2.com, we could specify an array of httpCredentials (username/password/origin):

await browser.newContext({httpCredentials: [
	{ username: 'user1', password: 'pass1', origin: 'https://server1.com' },
	{ username: 'user2', password: 'pass2', origin: 'https://server2.com' }
]);

To be discussed:

  1. backward compatibility creating context with non array httpCredentials
  2. new naming for array httpCredentials
  3. edge case when 1 httpCredentials does not have origin (what credentials to use for server.com ?):
await browser.newContext({httpCredentials: [
	{ username: 'user1', password: 'pass1' },
	{ username: 'user2', password: 'pass2', origin: 'https://server.com' }
]);
  1. edge case when 2 httpCredentials do not have origin (what credentials to use for server.com ?):
await browser.newContext({httpCredentials: [
	{ username: 'user1', password: 'pass1' },
	{ username: 'user2', password: 'pass2' }
]);
  1. edge case when 2 httpCredentials have the same origin (what credentials to use for server.com ?):
await browser.newContext({httpCredentials: [
	{ username: 'user1', password: 'pass1', origin: 'https://server.com' },
	{ username: 'user2', password: 'pass2', origin: 'https://server.com' }
]);

Activity

  1. SebastienRichert commented on Mar 28, 2023

    @SebastienRichert
    ContributorAuthor

    Regarding the edge case 3.,4.,5., question is whether we should:

    • either have defensive code that prevent the creation of new context:
      • unspecified origin credentials only allowed with array of 1 element
      • different credentials for same origin not allowed
      • ...
    • or always allow any input, and in a determinist way, go through the credentials list in the order they are defined, which would mean:
      • 3. uses user1/pass1
      • 4. uses user1/pass1
      • 5. uses user1/pass1
  2. tokyo-watcher commented on Sep 6, 2023

    @tokyo-watcher
  3. pavelfeldman commented on Aug 16, 2024

    @pavelfeldman
    Member

    Why was this issue closed?

    Thank you for your involvement. This issue was closed due to limited engagement (upvotes/activity), lack of recent activity, and insufficient actionability. To maintain a manageable database, we prioritize issues based on these factors.

    If you disagree with this closure, please open a new issue and reference this one. More support or clarity on its necessity may prompt a review. Your understanding and cooperation are appreciated.

  4. Gby56 commented on Jul 16, 2026

    @Gby56

    Hello Pavel Feldman (@pavelfeldman) , I saw this issue and encountered the same problem. I can try to make a PR for this

  5. Gby56 commented on Jul 16, 2026

    @Gby56

    Hi Dmitry Gozman (@dgozman) ! I use playwright for browser automation, people provide to us authentication details, sometimes we must crawl/review multiple web applications that use different auths, but we must use the same playwright context (weird, I know)
    Apparently Chromium/Firefox allow for multiple auths setup, Webkit doesn't, that's the main difference. I would like to use the native playwright feature instead of putting a proxy in front to handle all of this, since browsers do it very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions