配置双重身份验证
See Details
目录
你可以在你的 npm 用户账户上启用双重身份验证 (2FA),以防止未经授权访问你的账户和包,方法是使用移动应用中的 security-key 或 基于时间的一次性密码 (TOTP)。
¥You can enable two-factor authentication (2FA) on your npm user account to protect against unauthorized access to your account and packages, either by using a security-key or time-based one-time password (TOTP) from a mobile app.
先决条件
¥Prerequisites
在你的 npm 用户账户上启用 2FA 之前,你必须:
¥Before you enable 2FA on your npm user account, you must:
-
将你的 npm 客户端更新到 5.5.1 或更高版本。
¥Update your npm client to version 5.5.1 or higher.
-
要配置安全密钥,需要支持 WebAuthn 的现代浏览器。这将允许你配置具有 Apple 触控 ID、人脸识别 或 Windows Hello 以及物理按键(例如 Yubikey、Thetis 或 Feitian)的生物识别设备。
¥To configure a security-key requires a modern browser that support WebAuthn. This will allow you to configure a biometric devices featuring Apple Touch ID, Face ID, or Windows Hello as well as physical keys such as Yubikey, Thetis, or Feitian.
-
要配置 TOTP,你需要在移动设备上安装可以生成 OTP(例如 Authy、谷歌身份验证器 或 微软身份验证器)的身份验证器应用。
¥To configure TOTP you will need to install an authenticator application that can generate OTPs such as Authy, Google Authenticator, or Microsoft Authenticator on your mobile device.
有关支持的 2FA 方法的更多信息,请参阅“关于双重身份验证”。
¥For more information on supported 2FA methods, see "About two-factor authentication".
注意:npm 不接受 SMS(文本到调用)作为 2FA 方法。
¥Note: npm does not accept SMS (text-to-phone) as a 2FA method.
从网站配置 2FA
¥Configuring 2FA from the website
启用 2FA
¥Enabling 2FA
-
在 npm“登录”页面上,输入您的帐户详细信息并单击登录。
-
在页面的右上角,点击您的个人资料照片,然后点击帐户。
-
在账户设置页面的 "双重身份验证" 下,单击启用 2FA。
¥On the account settings page, under "Two-Factor Authentication", click Enable 2FA.
-
当出现提示时,请提供你当前的账户密码,然后单击确认密码继续。
¥When prompted provide your current account password and then click Confirm password to continue.
-
在 2FA 方法页面上,选择你要启用的方法,然后单击继续。有关支持的 2FA 方法的更多信息,请参阅“关于双重身份验证”。
¥On the 2FA method page, select the method you would like to enable and click Continue. For more information on supported 2FA methods, see "About two-factor authentication".
-
配置你选择的 2FA 方法:
¥Configure the 2FA method of your choice:
-
使用安全密钥时,为其提供名称并单击添加安全密钥。按照浏览器特定的步骤添加你的安全密钥。
¥When using a security-key, provide a name for it and click Add security key. Follow the browser specific steps to add your security-key.
-
以下是在 MacOS 上运行的 Microsoft Edge 的配置示例
¥Below is an example of configuration from Microsoft Edge running on a MacOS
-
在手机上使用身份验证器应用时,打开该应用并扫描两步验证页面上的二维码。输入应用生成的代码,然后单击“验证”。
¥When using an authenticator application on your phone, open it and scan the QR code on the two-step verification page. Enter the code generated by the app, then click Verify.
-
-
在恢复代码页上,将恢复代码复制到你的计算机或其他非第二重设备的安全位置。我们建议使用密码管理器。
¥On the recovery code page, copy the recovery codes to your computer or other safe location that is not your second factor device. We recommend using a password manager.
如果你无法访问第二重设备,恢复代码是确保你可以恢复账户的唯一方法。每个代码只能使用一次。你可以从 2FA 设置页面 查看并重新生成你的恢复代码。有关辅助账户恢复选项,请参阅“配置账户恢复选项”。
¥Recovery codes are the only way to ensure you can recover your account if you lose access to your second factor device. Each code can be used only once. You can view and regenerate your recovery code from your 2FA settings page. For secondary account recovery options, see "Configuring account recovery options."
-
确认你 已保存代码后,单击返回设置。
¥Click Go back to settings after confirming that you have saved your codes.
禁用 2FA 写入
¥Disabling 2FA for writes
查看 授权和写入 部分,了解有关启用此模式时需要 2FA 的不同操作的更多信息。
¥Check the Authorization and writes section for more information on different operations that requires 2FA when this mode is enabled.
注意:作为推荐设置,在设置 2FA 时会自动启用用于写入操作的 2FA。以下步骤说明了如何禁用它。
¥Note: As a recommended setting, 2FA for write operations are automatically enabled when setting up 2FA. The following steps explain how to disable it.
-
在 npm“登录”页面上,输入您的帐户详细信息并单击登录。
-
在页面的右上角,点击您的个人资料照片,然后点击帐户。
-
在账户设置页面的 "双重身份验证" 下,单击修改 2FA。
¥On the account settings page, under "Two-Factor Authentication", click Modify 2FA.
-
从 "管理双重身份验证" 导航到 "其他选项" 部分
¥From the "Manage Two-Factor Authentication" navigate to "Additional Options" section
-
清除 "写入操作需要双重身份验证" 的复选框并单击 "更新首选项"
¥Clear the checkbox for "Require two-factor authentication for write actions" and click "Update Preferences"
禁用 2FA
¥Disabling 2FA
如果你启用了 2FA,则可以将其从你的账户设置页面中删除。
¥If you have 2FA enabled, you can remove it from your account settings page.
注意:如果你是执行 2FA 的组织的成员,则不能删除 2FA。你可以从 "组织" 选项卡下的个人资料页面查看组织成员列表。
¥Note: You cannot remove 2FA if you are a member of an organization that enforces 2FA. You can view the list of organizations memberships from your profile page under the "Organizations" tab.
-
在 npm“登录”页面上,输入您的帐户详细信息并单击登录。
-
在页面的右上角,点击您的个人资料照片,然后点击帐户。
-
在账户设置页面的 "双重身份验证" 下,单击修改 2FA。
¥On the account settings page, under "Two-Factor Authentication", click Modify 2FA.
-
滚动到 "管理双重身份验证" 页面的底部,然后单击禁用 2FA。
¥Scroll to the bottom of the "Manage Two-Factor Authentication" page and click Disable 2FA.
-
同意浏览器的提示。
¥Agree to the prompt from the browser.
从命令行配置 2FA
¥Configuring 2FA from the command line