add the allowed hosts dynamically

This commit is contained in:
Andreas Zweili 2022-03-27 16:13:34 +02:00
parent 5e2b7350ea
commit d6090ad3b3
4 changed files with 27 additions and 2 deletions

View File

@ -3,3 +3,4 @@ POSTGRES_PASSWORD=password
DJANGO_SETTINGS_MODULE=network_inventory.settings.docker
DJANGO_DEBUG=False
DJANGO_SECRET_KEY=foo
DOMAIN=inventory.example.com

View File

@ -1,6 +1,12 @@
from socket import gethostname
from socket import gethostbyname_ex
from .base import *
ALLOWED_HOSTS = ["localhost", "127.0.0.1", "10.7.89.104"]
ALLOWED_HOSTS = [
gethostname(),
] + list(set(gethostbyname_ex(gethostname())[2]))
CSRF_TRUSTED_ORIGINS = [
"http://localhost:8080",

View File

@ -1,8 +1,16 @@
from socket import gethostname
from socket import gethostbyname
from socket import getfqdn
from .base import *
ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
getfqdn(),
gethostname(),
gethostbyname(gethostname()),
]
CSRF_TRUSTED_ORIGINS = [

View File

@ -1,7 +1,17 @@
from socket import gethostname
from socket import gethostbyname
from socket import getfqdn
from .base import *
ALLOWED_HOSTS = [
"inventory.2li.local",
"localhost",
"127.0.0.1",
getfqdn(),
gethostname(),
gethostbyname(gethostname()),
os.getenv("DOMAIN"),
]
# SECURITY WARNING: keep the secret key used in production secret!