-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Auth #9569
Comments
I'll throw a few more out there. Some don't wish to construct the header on their own but want to ensure the app is properly picking it up from wherever they're storing it.
Also worth noting that I've seen several systems in the past where they use a bespoke header for the token but for the most part our The only major missing case I see is when they use a query param or JSON property in the payload for the token. In which case we have to support letting them drop it into their particular storage of choice. |
Thanks @patrickhulce!
We could introduce There's no protocol methods for writing to IndexDB, so that will continue to require a chrome profile / puppeteer setup. We could do something bespoke using
Could you elaborate on this? |
I like this idea! A convenience for pre-populating is nice without having to spin up puppeteer 👍Though I might want to try to avoid flag bloat with some
Yeah I was just saying the missing case that isn't covered by |
It's true that user account/login state can be defined in lots of different ways. localStorage, cookies, indexedDB, etc. Stepping back, I don't see users actually asking for this. In fact, looking at #1418, it's us who are suggesting setting cookies/headers as a means to do this. Meanwhile, when an example of using puppeteer to login was posted, it quickly got the most 👍 reactions in the thread. Similarly, the WPT scripting language is mostly used to fill in login forms. My suspicion is that folks who currently have integration tests on their login-based webapp are logging into them with forms rather than prefilling *storage state or setting request headers. I also think this is far more user-friendly. IMO the ask here is to document using pptr to login and handing off to lighthouse. This comment laid the groundwork, but it could afford to be generalized. We should also mention the two backup solutions of.. A) extra-headers and B) chrome profile reuse. |
Thanks @paulirish. I do plan on making the puppeteer use-case the focal point of the documentation I'll write. Wanted to also cover all the other cases. I've started to uncover some possible gaps in LH's ability to do the alternatives, and think it's important to improve these shortcomings aswell as write the docs for it. These are blockers I've identified for providing a comprehensive guide for auth:
I'll switch focus to just writing the pupeteer docs now - even 2) can be circumvented as long as you use puppeteer to launch.
I wonder, if pupeteer is needed to simply fill a form, and WPT even has a scripting feature to do this ... maybe we should just do that? Instead of requiring puppeteer be thrown into the mix? |
Oh yes to be clear, massive +1 to supporting an actual e2e testing flow for using the UI as intended to login. Just wanted to make sure we were aware of the various auth mechanisms and can support them or at least address the required workarounds in this documentation. (for example sessionstorage is still impossibleish with a puppeteer prestep because we open the new tab, etc). |
(related: #1418. Separate issue b/c this is just me asking if my approach makes sense, and this got a bit too long-form for our internal chat)
So I'm starting to write docs for LH on authenticated pages. I know little about auth stuff. I see some stuff on JWT. And cookies. and then there's Basic auth. and feeling a bit lost, so let my run this by y'all.
Authorization: Basic ...
header (--extra-headers=./path/to/secret/headers.json
).Authorization: Bearer ...
--extra-headers "{\"Cookie\":\"test=true\"}"
is needed. There are some issues with this, see core: added capability to pass cookies as CLI parameter #9170 . The current proper way to set cookies (without overwriting what already exists) is via pupeteer / CDP - core: added capability to pass cookies as CLI parameter #9170 would make this much simpler.I want to make a local server that does a few different methods of auth to test stuff out. Here's a simple basic auth server in python: https://gist.github.com/dragermrb/108158f5a284b5fba806 . I'll probably make a cookie / token based one too.
The text was updated successfully, but these errors were encountered: