Skip to content

Commit

Permalink
django: track the base production settings
Browse files Browse the repository at this point in the history
This makes the production.example.py file inherit from production_base.py, which we then can edit in the future
  • Loading branch information
laggron42 committed Feb 12, 2025
1 parent e2e1b98 commit 52b9740
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
5 changes: 5 additions & 0 deletions admin_panel/admin_panel/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

SECRET_KEY = None

# WARNING: DO NOT ADD EXTERNAL HOSTS HERE!!
# If you want to expose your admin panel online, please follow this tutorial:
# https://github.com/Ballsdex-Team/BallsDex-DiscordBot/wiki/Serving-the-admin-panel-online
# THIS HAS SECURITY IMPLICATIONS, ENABLES PRIVILEGE ESCALATION AND REMOTE CODE EXECUTION

ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
Expand Down
13 changes: 2 additions & 11 deletions admin_panel/admin_panel/settings/production.example.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
# Copy this file as "production.py" and set the environment variable
# DJANGO_SETTINGS_MODULE="admin_panel.settings.production" to enable serving over the internet
# DJANGO_SETTINGS_MODULE=admin_panel.settings.production to enable serving over the internet

from .base import *

DEBUG = False

# Force python-social-auth (Discord OAuth2) to use https redirection
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True

# Correctly read the headers when using a proxy like nginx
# Failing to configure this setting will result in CSRF errors in HTTPS
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
from .production_base import *

# Generate a long random string here for your secret key. It is important to keep it secret,
# leaking it could allow attackers to do privilege escalation.
Expand Down
10 changes: 10 additions & 0 deletions admin_panel/admin_panel/settings/production_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from .base import *

DEBUG = False

# Force python-social-auth (Discord OAuth2) to use https redirection
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True

# Correctly read the headers when using a proxy like nginx
# Failing to configure this setting will result in CSRF errors in HTTPS
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")

0 comments on commit 52b9740

Please sign in to comment.