Commit caced58a authored by Simon Chabot's avatar Simon Chabot
Browse files

feat(allowed-http-host-headers): automatically add default hostname to the...

feat(allowed-http-host-headers): automatically add default hostname to the allowed list on debug mode
parent f78639407dae
......@@ -25,6 +25,7 @@ import sys
import pyramid
import inspect
import logging
from socket import gethostname
from datetime import datetime
......@@ -410,7 +411,9 @@ def includeme(config):
"For example: allowed-http-host-headers=example.com,logilab.fr"
)
else:
cwconfig["allowed-http-host-headers"] = "localhost,.locahost,127.0.0.1"
cwconfig[
"allowed-http-host-headers"
] = f"localhost,.locahost,127.0.0.1,{gethostname()}"
log.warning(
"this instance is being launched in debug mode **without** any value for the "
"setting 'allowed-http-host-headers' in the '[WEB]' section of your configuration "
......
......@@ -22,6 +22,7 @@ from cubicweb import _
import os
import hmac
from socket import gethostname
from uuid import uuid4
from os.path import dirname, join, exists, split, isdir
......@@ -258,7 +259,7 @@ class WebConfiguration(BaseWebConfiguration):
"any value (use with caution). "
"Domains starting with a '.' are treated as subdomain wildcard."
"In debug mode, if this setting is empty, it will be set to "
"'localhost,.locahost,127.0.0.1'."
f"'localhost,.locahost,127.0.0.1,{gethostname()}'."
),
"group": "web",
"level": 0,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment