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

NPM_TOKEN for node-core-utils to auto publish to npm #618

Closed
mmarchini opened this issue Jun 10, 2021 · 19 comments
Closed

NPM_TOKEN for node-core-utils to auto publish to npm #618

mmarchini opened this issue Jun 10, 2021 · 19 comments

Comments

@mmarchini
Copy link
Contributor

Request to create a NPM_TOKEN on node-core-utils containing an npm automation token for the nodejs-foundation npm user so that we can automate releases for node-core-utils.

Requires 2 approvals from @nodejs/tsc and 2 approvals from @nodejs/community-committee.

@richardlau
Copy link
Member

This would be a change in policy:
https://github.com/nodejs/admin/blob/main/npm-management.md

The purpose of the nodejs-foundation user is not to enable Build Workgroup members to publish npm modules, that should be left to the module collaborators.

@mmarchini
Copy link
Contributor Author

mmarchini commented Jun 10, 2021

Nice catch, although I don't interpret that item as "don't use tokens with this user", but rather "you shouldn't login into this user to publish the module manually" (and I'm pretty sure we've done that with some modules anyway).

Either way, we can change our policy or create a new user for each module (saving the credentials on 1password/lastpass), which is a pain but would prevent the "token can publish any module" security concern.

@Trott
Copy link
Member

Trott commented Jun 11, 2021

I'm 👍 on this, and would also happily 👍 something that clarified the policy.

@mhdawson
Copy link
Member

It was the ""you shouldn't login into this user to publish the module manually" part that was intended.

I think for auto publishing this makes sense, and I don't see why we'd create another user. I'm +1 to this as well.

@joyeecheung
Copy link
Member

saving the credentials on 1password/lastpass

Don't we do that sort of thing with the secrets repo using dotgpg?

@mmarchini
Copy link
Contributor Author

Don't we do that sort of thing with the secrets repo using dotgpg?

Yes but that also makes it harder of us to manage access to secrets, which is why I also opened nodejs/build#2647.

@bnb
Copy link
Contributor

bnb commented Jun 14, 2021

+1

@mhdawson
Copy link
Member

@mmarchini do you want to get together to create the required token. I can access the nodejs-foundation account but would like to do it together so that we create what you need (which I'm not 100% sure I'd get right on my own).

@targos
Copy link
Member

targos commented Mar 30, 2022

@mhdawson

  1. Go to https://www.npmjs.com/settings/nodejs-foundation/tokens/new
  2. Enter the nodejs-foundation account's password
  3. Name: NPM_TOKEN secret to publish node-core-utils ?
    Type: "Automation"
    Click "Generate Token"
  4. Copy the generated token (it starts with "npm_")
  5. Go to https://github.com/nodejs/node-core-utils/settings/secrets/actions/new
  6. Name: NPM_TOKEN
    Value: the token you copied at 4.
    Click "Add secret"

@mhdawson
Copy link
Member

mhdawson commented Apr 7, 2022

@targos ok, done but not sure that will be enough since 2FA is enabled.

@targos
Copy link
Member

targos commented Apr 8, 2022

It should be fine. Automation tokens bypass 2FA. Thank you!

@targos
Copy link
Member

targos commented Apr 8, 2022

@targos ok, done but not sure that will be enough since 2FA is enabled.

Looks like you were right: https://github.com/nodejs/node-core-utils/runs/5885136215?check_suite_focus=true

I don't know what's blocking it, though. I have setup automation tokens without issues before (on an account that has 2FA enabled too).

@targos
Copy link
Member

targos commented Apr 14, 2022

I checked on https://www.npmjs.com/package/node-core-utils/access and the package doesn't enforce 2FA so I really don't know what's wrong.

@targos
Copy link
Member

targos commented Apr 14, 2022

nodejs-foundation also has access:
image

@targos
Copy link
Member

targos commented Apr 14, 2022

@mhdawson are you sure that you didn't create a publish token instead of an automation token?

@mhdawson
Copy link
Member

@targos I thought I followed your instructions above exactly. What would be the difference between the two (ie what did I miss in the instructions above that would result in a publish instead of automation token). Once I understand that I can try again.

@aduh95
Copy link
Contributor

aduh95 commented Apr 19, 2022

See https://github.blog/changelog/2020-10-02-npm-automation-tokens/

An automation token will bypass the 2FA when publishing, while the publish token will not:
screenshot from npm website

@mhdawson
Copy link
Member

@aduh95 k thanks, updated and I should have it correct this time.

@targos
Copy link
Member

targos commented Apr 19, 2022

It worked this time: https://github.com/nodejs/node-core-utils/runs/6081510688?check_suite_focus=true
Thanks!

@targos targos closed this as completed Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants