Skip to content
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

fix: remove unnecessary logging for webauthn auth #5077

Closed
wants to merge 1 commit into from

Conversation

hfaulds
Copy link
Contributor

@hfaulds hfaulds commented Jun 24, 2022

Description

When authenticating using Webauthn it is unnecessary to log Log in on.... This PR hides that logging in that case.

Prior to this PR the output looks like:

image

An alternative approach would be to use the existing auth handler polymorphism, rather than adding branching into lib/auth/legacy.js. If we introduce a new lib/auth/webauthn.js handler and move our legacy.js logic there, then legacy.js can log the notice and then call webauthn.js. This would avoid the branching introduced by this PR and the unfortunate confusion of legacy.js checking if authType == 'legacy'. The downside of that approach is the merge conflicts it will create with ongoing work to these files, and the naming confusion around legacy and webauthn.

References

@hfaulds hfaulds changed the title remove unnecessary prompt for webauthn auth fix: remove unnecessary prompt for webauthn auth Jun 24, 2022
@hfaulds hfaulds changed the title fix: remove unnecessary prompt for webauthn auth fix: remove unnecessary logging for webauthn auth Jun 24, 2022
@hfaulds hfaulds force-pushed the hfaulds/hide-unnecessary-prompt-for-webauthn branch 2 times, most recently from ffabff9 to 4f2bf86 Compare June 24, 2022 09:32
@npm-cli-bot
Copy link
Collaborator

npm-cli-bot commented Jun 24, 2022

no statistically significant performance changes detected

timing results
app-large clean lock-only cache-only cache-only
peer-deps
modules-only no-lock no-cache no-modules no-clean no-clean
audit
npm@8 35.125 ±1.19 18.420 ±0.01 16.582 ±0.12 19.063 ±0.73 2.981 ±0.01 2.910 ±0.11 2.496 ±0.06 11.431 ±0.04 2.307 ±0.12 3.404 ±0.12
#5077 34.532 ±0.89 18.885 ±0.52 16.560 ±0.01 19.554 ±0.99 2.950 ±0.04 3.005 ±0.13 2.390 ±0.06 11.757 ±0.27 2.371 ±0.05 3.366 ±0.20
app-medium clean lock-only cache-only cache-only
peer-deps
modules-only no-lock no-cache no-modules no-clean no-clean
audit
npm@8 24.179 ±0.13 14.010 ±0.09 12.272 ±0.02 13.594 ±0.49 2.777 ±0.02 2.701 ±0.03 2.390 ±0.04 8.437 ±0.10 2.239 ±0.07 3.010 ±0.06
#5077 24.061 ±0.16 13.901 ±0.32 12.395 ±0.27 13.305 ±0.10 2.815 ±0.15 2.823 ±0.03 2.323 ±0.00 8.431 ±0.19 2.268 ±0.02 3.038 ±0.00

@hfaulds hfaulds force-pushed the hfaulds/hide-unnecessary-prompt-for-webauthn branch 2 times, most recently from 6ba885f to a100c69 Compare June 24, 2022 10:24
@hfaulds hfaulds marked this pull request as ready for review June 24, 2022 10:33
@hfaulds hfaulds requested a review from a team as a code owner June 24, 2022 10:33
@hfaulds hfaulds force-pushed the hfaulds/hide-unnecessary-prompt-for-webauthn branch from a100c69 to 5c4116d Compare June 24, 2022 10:36
@darcyclarke
Copy link
Contributor

@hfaulds @MylesBorins why is this "unnecessary"? The whole reason to log the location is for end-user clarity/security. npm users can be configured to use any number of third-party registries & displaying that information on any login seems useful (whether that's before sending any kind sensitive auth information, headers or even, in this case, redirecting the user to login in to a website in a browser).

@jumoel
Copy link
Contributor

jumoel commented Jun 25, 2022

@darcyclarke It’s also showing a URL in the output that prompts for login.

@hfaulds
Copy link
Contributor Author

hfaulds commented Jun 27, 2022

@darcyclarke I updated the PR description with a screenshot of what the output looked like prior to this PR

@ljharb
Copy link
Collaborator

ljharb commented Jun 27, 2022

The registry url and the webauthn URL aren’t the same though. Isn’t the registry url important?

@MylesBorins
Copy link
Contributor

MylesBorins commented Jun 27, 2022

@ljharb two things to clarify

  1. it isn't a webauthn URL, this flag is essentially for "Authenticate through the website". The names are confusing. "WebAuthn" is a spec for supporting specific multi factor devices.
  2. The URL you are forwarded to will always be for the registry you are authenticating with, so the two lines are superfluous. There is never a case where you would use this flag and get a url to click on that isn't for the registry you are authenticating with.

Also worth mentioning, this functionality has not yet been implemented by any public or private registry. we have something currently in staging that we are testing which is where we found this unnecessary copy that makes the login experience noisy

@ljharb
Copy link
Collaborator

ljharb commented Jun 27, 2022

@MylesBorins in the screenshot, the registry is registry-staging.npm.red, and the web URL is www-staging.npm.red - if the domains can be different then how is "There is never a case where you would use this flag and get a url to click on that isn't for the registry you are authenticating with." accurate?

@MylesBorins
Copy link
Contributor

ok I'm seeing the distinction now between the registry URL and the auth URL... one of which is registry.npmjs.com and the other which would be www.npmjs.com

We can keep both, it just seems noisy. Maybe we could change the copy to be a bit more explicit than the current text... previously when logging in you would be prompted for username and have no insight into where you were logging in. Now you will see a URL you are clicking. While it won't have necessarily have "registry" in the URL it will be explicitly tied to the registry / service you are authenticating with.

@jumoel
Copy link
Contributor

jumoel commented Jul 1, 2022

@MylesBorins: So what would you prefer we do? 🙂

@MylesBorins
Copy link
Contributor

I think we can still log this information but at a different log level (verbose rather than info). I think we can consider this a post GA improvement rather than exit criteria.

What isn't clear is if we want to make this loglevel vebose for all login, or just for web based login. As such I think we can punt on this being blocking

Thoughts?

@darcyclarke darcyclarke assigned wraithgar and unassigned fritzy Jul 11, 2022
@wraithgar wraithgar added Needs Discussion is pending a discussion pr: needs tests requires tests before merging and removed Needs Discussion is pending a discussion pr: needs tests requires tests before merging labels Jul 12, 2022
@wraithgar
Copy link
Member

I think #5172 might fix this in a much more holistic way.

@MylesBorins
Copy link
Contributor

@wraithgar would the account for the npm info logging the name of the registry?

@wraithgar
Copy link
Member

@wraithgar would the account for the npm info logging the name of the registry?

That would still be there, but the default loglevel is notice which means it would not show up on stdout unless the user had set their loglevel to info or higher. It's very important it's still there in some form, as all log messages to go the logfile (we are running this through replaceInfo right?), and that's important for support/debugging.

This PR means we don't have to worry about this logging showing up as apparently duplicate info.

@wraithgar
Copy link
Member

I really honestly don't see what the problem is here. It really is not that noisy and this does feel like anticipating a problem that doesn't exist. I don't think changing it to info helps (then you don't see the message on other forms of login by default), and I don't think removing it for one type of login helps (the registry itself is a config value that carries a lot of meaning to the cli and to the user, independent of the web url it then uses).

Especially given that the web login url is not the same as the registry, I think both are appropriate.

Also, I was in error about the other PR being related, that one affects publish, not login.

@wraithgar wraithgar closed this Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Discussion is pending a discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants