Skip to content

Commit

Permalink
refactor: Replace dotenv with django-environ and enhance security
Browse files Browse the repository at this point in the history
  • Loading branch information
BDlhj committed Nov 24, 2024
1 parent 7db05af commit ff13a24
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
10 changes: 6 additions & 4 deletions backoffice/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@
import os
from pathlib import Path

from dotenv import load_dotenv
import environ

load_dotenv()
env = environ.Env(DEBUG=(bool, False))

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent

environ.Env.read_env(os.path.join(BASE_DIR, ".env"))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("SECRET_KEY")
SECRET_KEY = env("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False

ALLOWED_HOSTS = []

Expand Down
2 changes: 2 additions & 0 deletions backoffice/settings/local.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from .base import * # noqa: F401, F403

DEBUG = True

INTERNAL_IPS = [
"127.0.0.1",
"localhost",
Expand Down
2 changes: 0 additions & 2 deletions backoffice/settings/prod.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from .base import * # noqa: F401, F403

DEBUG = False

ALLOWED_HOSTS = ["*"] # TODO: 추후 도메인 설정 후 변경

# TODO: 추후 도메인 설정 후 CSRF_TRUSTED_ORIGINS, CORS_ALLOWED_ORIGINS에 추가
18 changes: 17 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ django = "^5.1.3"
python-dotenv = "^1.0.1"
django-cors-headers = "^4.6.0"
django-extensions = "^3.2.3"
django-environ = "^0.11.2"


[tool.poetry.group.dev.dependencies]
Expand Down

0 comments on commit ff13a24

Please sign in to comment.