-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(npm): add hook for getting the authentication header #2664
Conversation
f6dfc1d
to
8751e67
Compare
@arcanis Is there something wrong with this PR? If there is I'd like to fix it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @waterfoul! Sorry for the delay, it felt off my radar 🙁
Just two nits (and a rebase); I'd have done it myself but your PR doesn't seem open to maintainers edit (probably because of your org settings).
declined: | ||
- "@yarnpkg/plugin-compat" | ||
- "@yarnpkg/plugin-npm-cli" | ||
- "@yarnpkg/cli" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to mark @yarnpkg/cli
as minor as well.
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const effectiveConfiguration = npmConfigUtils.getAuthConfiguration(registry, {configuration, ident}); | ||
const mustAuthenticate = shouldAuthenticate(effectiveConfiguration, authType); | ||
|
||
if (!mustAuthenticate) | ||
return null; | ||
|
||
const header = await configuration.reduceHook((hooks: Hooks) => { | ||
return hooks.getNpmAuthenticationHeader; | ||
}, undefined, registry, {configuration, ident}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be a good time to use an object instead of multiple arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep things uniform for now, until it gets fixed in a sweeping pass. Given that BC will have to be preserved somehow, new hooks will likely follow a slightly different format.
I forgot to wait for your fixes 🤦♀️ Will fix it on master, nevermind. |
What's the problem this PR addresses?
Adds a hook for adding authentication headers, intended to be used for OAuth style authentication flows.
Closes #2067
...
How did you fix it?
I used reduceHook inside getAuthenticationHeader to collect the potential values from the hook, then return the provided value if there is one instead of checking npmAuthToken or npmAuthIdent
...
Checklist