简体   繁体   English

以下内容是否足以保护我的 heroku 部署的密钥和数据库密码?

[英]Is the following enough to protect my secret key and database password for heroku deployment?

I have added the environment variables through to get secret key database name and password.我已经通过添加环境变量来获取密钥数据库名称和密码。 Now anything else to make it more secure.Let me know.现在还有什么可以让它更安全的。让我知道。

Used "Advance system settings" and under that added environment variables in "User variables".使用“高级系统设置”并在“用户变量”中添加环境变量。 Also this is going to be my first deployment on 'heroku' that's why following a tutorial.这也将是我在“heroku”上的第一次部署,这就是为什么要遵循教程。

SECRET_KEY = os.environ['DB_SECRET']

databases数据库

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'portfoliodb',
        'USER': os.environ.get('DB_USER'),
        'PASSWORD': os.environ.get('DB_PASS'),
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Heroku has a package that handles that for you. Heroku 有一个 package 可以为您处理。 More info here .更多信息在这里 Essentially, it overrides default with secure credentials automatically generated in the Heroku platform.本质上,它使用在 Heroku 平台中自动生成的安全凭证覆盖默认值。

Add the following import statement to the top of settings.py:将以下导入语句添加到 settings.py 的顶部:

import django_heroku

Then add the following to the bottom of settings.py:然后将以下内容添加到 settings.py 的底部:

Activate Django-Heroku.激活 Django-Heroku。

django_heroku.settings(locals())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Heroku部署错误:Django_Secret_key环境变量配置不正确 - Heroku deployment error : ImproperlyConfigured Django_Secret_key environment variable Git/Heroku - 如何隐藏我的 SECRET_KEY? - Git/Heroku - How to hide my SECRET_KEY? 我正在尝试将我的 Django 项目部署到 Heroku 但关于我的 SECRET_KEY 的错误不断出现 - I am trying to deploy my Django project to Heroku but an error regarding my SECRET_KEY keeps appearing 我在Heroku上的Django应用程序中添加了SECRET_KEY配置变量,但现在在本地无法使用 - I added a SECRET_KEY config variable to my Django app on Heroku but now it won't work locally 从 Heroku Git Repo 中删除密钥 - Removing Secret Key from Heroku Git Repo Django上传到Github,除了secret_key还有什么重要的变量需要保密/保护吗? - Django uploading to Github, any important variables besides secret_key to keep a secret/protect? 在Django中,如何使用SECRET_KEY解密数据库和cookie中的会话ID? - In Django how to decrypt the session id in database and in cookie with my SECRET_KEY? 为什么我的 Heroku 部署无法识别我的 Procfile? - Why is my Heroku deployment not recognising my Procfile? 在 Heroku 部署期间无法填充数据库表? - Cannot populate database table during Heroku deployment? 部署到Heroku后如何与postgresql数据库连接? - How to connect with postgresql database after deployment to Heroku?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM