@reggi/path-to-regexp
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: Requiring 2FA for package publishing and settings modification |
| 3 | --- |
| 4 | |
| 5 | import shared from '~/shared.js' |
| 6 | |
| 7 | To protect your packages, as a package publisher, you can require everyone who has write access to a package to have two-factor authentication (2FA) enabled. This will require that users provide 2FA credentials in addition to their login token when they publish the package. For more information, see "[Configuring two-factor authentication][config-2fa]". |
| 8 | |
| 9 | You may also choose to allow publishing with either two-factor authentication _or_ with [automation tokens][creating-automation-token]. This lets you configure automation tokens in a CI/CD workflow, but requires two-factor authentication from interactive publishes. |
| 10 | |
| 11 | ## Configuring two-factor authentication |
| 12 | |
| 13 | 1. <>{shared['user-login'].text}</> |
| 14 | |
| 15 | <>{shared['user-login'].image}</> |
| 16 | |
| 17 | 2. Navigate to the package on which you want to require a second factor to publish or modify settings. |
| 18 | |
| 19 | 3. Click **Settings**. |
| 20 | |
| 21 | <Screenshot src="/packages-and-modules/securing-your-code/2fa-package-admin.png" alt="Screenshot showing the admin tab on a package page" /> |
| 22 | |
| 23 | 4. Under "Publishing access", select the requirements to publish a package. |
| 24 | |
| 25 | 1. **Dont require two-factor authentication** |
| 26 | With this option, a maintainer can publish a package or change the package settings whether they have two-factor authentication enabled or not. This is the least secure setting. |
| 27 | |
| 28 | 2. **Require two-factor authentication or automation tokens or granular access token** |
| 29 | With this option, maintainers must have two-factor authentication enabled for their account. If they publish a package interactively, using the `npm publish` command, they will be required to enter 2FA credentials when they perform the publish. However, maintainers may also create an [automation token][creating-automation-token] or a [granular access token][creating-granular-access-token] and use that to publish. A second factor is _not_ required when using a token, making it useful for continuous integration and continuous deployment workflows. |
| 30 | |
| 31 | 3. **Require two-factor authentication and disallow tokens** |
| 32 | With this option, a maintainer must have two-factor authentication enabled for their account, and they must publish interactively. Maintainers will be required to enter 2FA credentials when they perform the publish. Automation tokens and granular access tokens cannot be used to publish packages. |
| 33 | |
| 34 | <Screenshot src="/packages-and-modules/securing-your-code/2fa-package-setting.png" alt="Screenshot showing the require two-factor option for a package" /> |
| 35 | |
| 36 | 5. Click **Update Package Settings**. |
| 37 | |
| 38 | [config-2fa]: configuring-two-factor-authentication |
| 39 | [creating-automation-token]: creating-and-viewing-access-tokens#creating-granular-access-tokens-on-the-website |
| 40 | [creating-granular-access-token]: creating-and-viewing-access-tokens#creating-granular-access-tokens-on-the-website |