Rotating Anon, Service, and JWT Secrets
本故障排除指南是关于轮换 旧版匿名、service_role API 密钥 的。我们正在弃用旧版,并建议迁移到新版 API 密钥。想了解更多关于 API 密钥的信息,请参考 API 文档。
🌐 This troubleshooting guide is about rotating Legacy anon, service_role API keys. We are deprecating Legacy, and recommend migrating to New API keys. To learn more about API keys, refer to the API documentation.
一旦 JWT 密钥被重新生成,所有当前的 API 密钥将立即失效,使用它们的所有连接也会被切断。你需要部署新的密钥才能让连接重新工作。通过迁移到新的 API 密钥可以避免停机。
🌐 Once the JWT secret is regenerated, all current API secrets will be immediately invalidated, and all connections using them will be severed. You will need to deploy the new secrets for connections to begin working again. You can avoid downtime by migrating to new API Keys.
你有没有不小心把服务密钥提交到公共仓库里?或者你可能经常为安全合规而更换密钥。无论出于什么原因,这里有一个方法可以帮你为 Supabase 项目更换密钥。
🌐 Have you ever accidentally committed a service key to a public repo? Or maybe rotating keys is something you regularly do for security compliance. Whatever the reason, here's how to rotate the keys for your Supabase project.
如果你还没有迁移到非对称 JWT 签名密钥:
🌐 If you haven’t migrated to asymmetric JWT signing keys:
我们建议你迁移到非对称 JWT 签名密钥以及可发布/私密的 API 密钥,因为现在已经无法再轮换旧的匿名、服务和 JWT 密钥了。你可以查看这个 入门指南 来了解迁移到非对称 JWT 签名密钥的步骤。
🌐 We recommend that you migrate to asymmetric JWT signing keys and publishable/secret API keys as it is no longer possible to rotate the legacy anon, service and JWT secrets. You can view this Get Started guide for steps to migrate to asymmetric JWT signing keys.
如果你已经迁移到了新的对称 JWT 签名密钥:
🌐 If you have migrated to new symmetric JWT signing keys:
- 在 Supabase 控制面板中转到 项目设置 → JWT 密钥
- 导航到 JWT 签名密钥 标签。
- 点击“旋转密钥”。这会将当前密钥移动到“以前使用的密钥”
- 选择你之前使用的密钥的三点图标(操作图标),然后点击“撤销”。如果你不“撤销”这个密钥,旧的密钥仍然有效。
相关阅读 #
🌐 Further readings