gpt4 book ai didi

python - Django key 泄露

转载 作者:太空宇宙 更新时间:2023-11-03 10:47:36 26 4
gpt4 key购买 nike

我想知道如果生产 key 被泄露需要采取哪些步骤。幸运的是,情况并非如此,但还是很高兴知道。

特别是,如果简单地将旧 key 交换为新生成的 key ,会发生什么情况?由于它用于生成哈希,是否会破坏整个系统或使其不稳定?

在妥协的情况下,响应是否会像生成新 key 并将其插入生产设置一样简单?

最佳答案

SECRET_KEY用于以下用途:

  • 所有 session ,如果您使用除 django.contrib.sessions.backends.cache 之外的任何其他 session 后端,或者使用默认的 get_session_auth_hash()。
  • 如果您使用 CookieStorage 或 FallbackStorage,则为所有消息。
  • 所有 PasswordResetView token 。
  • 任何加密签名的使用,除非提供不同的 key 。

"If you rotate your secret key, all of the above will be invalidated. Secret keys are not used for passwords of users and key rotation will not affect them."

您可以使用以下函数生成新 key :

from django.core.management.utils import get_random_secret_key

print(get_random_secret_key())

只需将打印的结果复制/粘贴到您的 settings.py 中即可。

关于python - Django key 泄露,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58576377/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com