Skip to content

Commit

Permalink
refactor: Strengthen security regarding debug, csrf, cors
Browse files Browse the repository at this point in the history
  • Loading branch information
BDlhj committed Nov 24, 2024
1 parent af93805 commit 7db05af
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
10 changes: 10 additions & 0 deletions backoffice/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,13 @@
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

CSRF_TRUSTED_ORIGINS = [
"http://localhost:8000",
"http://127.0.0.1:8000",
]

CORS_ALLOWED_ORIGINS = [
"http://localhost:8000",
"http://127.0.0.1:8000",
]
5 changes: 0 additions & 5 deletions backoffice/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@
"localhost",
]

CSRF_TRUSTED_ORIGINS = [
"http://localhost:8000",
"http://127.0.0.1:8000",
]

CORS_ALLOW_ALL_ORIGINS = True
10 changes: 1 addition & 9 deletions backoffice/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,4 @@

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

CSRF_TRUSTED_ORIGINS = [
"http://localhost:8000",
"http://127.0.0.1:8000",
] # TODO: 추후 도메인 설정 후 변경

CORS_ALLOWED_ORIGINS = [
"http://localhost:8000",
"http://127.0.0.1:8000",
] # TODO: 추후 도메인 설정 후 변경
# TODO: 추후 도메인 설정 후 CSRF_TRUSTED_ORIGINS, CORS_ALLOWED_ORIGINS에 추가
13 changes: 10 additions & 3 deletions backoffice/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from debug_toolbar.toolbar import debug_toolbar_urls
from django.conf import settings
from django.contrib import admin
from django.urls import path
from django.urls import include, path

urlpatterns = [
path("admin/", admin.site.urls),
] + debug_toolbar_urls()
]

if settings.DEBUG:
import debug_toolbar

urlpatterns += [
path("__debug__/", include(debug_toolbar.urls)),
]

0 comments on commit 7db05af

Please sign in to comment.