Merge pull request #29 from wulkanowy/feature/autogenerate_secret_key

Autogenerate secret key
This commit is contained in:
Pengwius 2021-01-28 21:17:36 +01:00 committed by GitHub
commit 1563d778dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 3 additions and 38 deletions

View file

@ -1 +0,0 @@
SECRET_KEY = VULCANWEBKEY

View file

@ -25,12 +25,7 @@ And in frontend:
```shell
npm install
```
## 2. Create .env and make migrations
In the .env file put the code:
```shell
SECRET_KEY = VULCANWEBKEY
```
After saving the files, we migrate with these commands:
## 2. Make migrations
```shell
python manage.py makemigrations
python manage.py migrate

View file

@ -1,29 +1,5 @@
::To jest to samo co w pliku install.exe
pip install -r requirements.txt
echo SECRET_KEY = VULCANWEBKEY > .env
::Kiedyś to SECRET_KEY będzie generowany przez skrypt NIE RUSZAĆ!!!
::setLocal EnableDelayedExpansion
::set str=ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
::set /a P=!random!%%36
::set znak1=!str:~%P%,1!
::set /a P=!random!%%36
::set znak2=!str:~%P%,1!
::set /a P=!random!%%36
::set znak3=!str:~%P%,1!
::set /a P=!random!%%36
::set znak4=!str:~%P%,1!
::set /a P=!random!%%36
::set znak5=!str:~%P%,1!
::set /a P=!random!%%36
::set znak6=!str:~%P%,1!
::set /a P=!random!%%36
::set znak7=!str:~%P%,1!
::set /a P=!random!%%36
::set znak8=!str:~%P%,1!
::set /a P=!random!%%36
::set znak9=!str:~%P%,1!
::set "key=%znak1%%znak2%%znak3%%znak4%%znak5%%znak6%%znak7%%znak8%%znak9%"
::echo SECRET_KEY = %key% > .env
python manage.py makemigrations
python manage.py migrate
npm install

Binary file not shown.

View file

@ -1,6 +1,5 @@
beautifulsoup4==4.9.3
bs4==0.0.1
Django==3.1.3
python-dotenv==0.15.0
requests==2.24.0
cryptography==3.2.1

View file

@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
from pathlib import Path
import os
import dotenv
from cryptography.fernet import Fernet
ROOT_PATH = os.path.dirname(__file__)
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@ -22,11 +22,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
dotenv_file = os.path.join(BASE_DIR, ".env")
if os.path.isfile(dotenv_file):
dotenv.load_dotenv(dotenv_file)
SECRET_KEY = os.environ['SECRET_KEY'] # Instead of your actual secret key
SECRET_KEY = Fernet.generate_key().decode('utf-8')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True