From 250b005f59a67f1ebd6d9b3bece8562007964737 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Fri, 24 Feb 2023 00:29:16 +0800 Subject: [PATCH] Hid secret key in .env file --- .gitignore | 160 +++++++++++++++++++++++++++++++++++++ Pipfile | 1 + Pipfile.lock | 10 ++- project/config/settings.py | 3 +- project/db.sqlite3 | Bin 139264 -> 139264 bytes 5 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..68bc17f --- /dev/null +++ b/.gitignore @@ -0,0 +1,160 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/Pipfile b/Pipfile index 31a082c..2498513 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ djangorestframework = "*" djoser = "*" djangorestframework-simplejwt = "*" django-cors-headers = "*" +python-decouple = "*" [dev-packages] autopep8 = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 3126d24..87e90aa 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "24c6a4fe52c048f750d36c10e0e1e0fd578de1b2455b1dd082ef830c272e461a" + "sha256": "2a24356df675b56c84eb1a0af12b896f6fc152d487c390124b2ed9d68d884ea0" }, "pipfile-spec": 6, "requires": { @@ -394,6 +394,14 @@ "markers": "python_version >= '3.7'", "version": "==2.6.0" }, + "python-decouple": { + "hashes": [ + "sha256:1596dad2670cca5b1f87d087d9adb6a1958c590df346b85d4b19a9d6f0d52cef", + "sha256:e88a8d6bdf3b07d471a854099e455e20a6fa7a4d6ecf8631b250e3db654336e6" + ], + "index": "pypi", + "version": "==3.7" + }, "python3-openid": { "hashes": [ "sha256:33fbf6928f401e0b790151ed2b5290b02545e8775f982485205a066f874aaeaf", diff --git a/project/config/settings.py b/project/config/settings.py index 89b8d9f..c773bb6 100644 --- a/project/config/settings.py +++ b/project/config/settings.py @@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.1/ref/settings/ """ from pathlib import Path +from decouple import config # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -20,7 +21,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-=p&04v6!#hvz*g1ht4c7tjcsy6*e61u7tkv8ird9b*#%lo$kjx' +SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True diff --git a/project/db.sqlite3 b/project/db.sqlite3 index 5fd6d92e5898970b1bc441eda26db44ae2f0dd5f..d1819e5ee2b81a8c6cf69afa9b1849ea746ffbe6 100644 GIT binary patch delta 153 zcmZoTz|nAkV}dke_(U0J#_){^;rg6n`6a31%*@7&lMnI;H(%D@ep#Q<>;h{qe=mRH zW<`TA{^=?FOq%Qr3=GBkj*8PK@H5H#8k$>~80r~Yni-fGWTa*&l%y7yC>Q~im}@%9 ymgMK8rsU`3m!%dZ;h{ie} z21XV}=9Q(nxeN>pj+%~!(=YHd$;bgEjm-6o3=B=o46;j$N))OxfySjOl;r26rsOXZ HU=jcT5Hc)@