Skip to content

Commit

Permalink
Make allowed_host variable a list.
Browse files Browse the repository at this point in the history
  • Loading branch information
antarcticrainforest committed Apr 23, 2024
1 parent d6cf40f commit 196cd3d
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions django_evaluation/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ def _set_favicon(html_color: str, project_root: Path) -> None:
if not DEV:
STATIC_ROOT = str(Path(PROJECT_ROOT) / "static")

INSTITUTION_LOGO = _get_logo(
web_config.get("institution_logo", ""), PROJECT_ROOT
)
INSTITUTION_LOGO = _get_logo(web_config.get("institution_logo", ""), PROJECT_ROOT)
FREVA_LOGO = f"{STATIC_URL}img/by_freva_transparent.png"
MAIN_COLOR = _get_conf_key(web_config, "main_color", "Tomato", False)
_set_favicon(MAIN_COLOR, Path(PROJECT_ROOT))
Expand All @@ -151,9 +149,7 @@ def _set_favicon(html_color: str, project_root: Path) -> None:
"Germany",
]
HOMEPAGE_HEADING = web_config.get("homepage_heading") or "Lorem ipsum dolor."
ABOUT_US_TEXT = (
web_config.get("about_us_text") or "Hello world, this is freva."
)
ABOUT_US_TEXT = web_config.get("about_us_text") or "Hello world, this is freva."
CONTACTS = web_config.get("contacts") or ["[email protected]"]
if isinstance(CONTACTS, str):
CONTACTS = [c for c in CONTACTS.split(",") if c.strip()]
Expand All @@ -176,9 +172,7 @@ def _set_favicon(html_color: str, project_root: Path) -> None:
##################################################
##################################################
# The server for LDAP configuration
AUTH_LDAP_SERVER_URI = os.environ.get(
"AUTH_LDAP_SERVER_URI", "ldap://idm-dmz.dkrz.de"
)
AUTH_LDAP_SERVER_URI = os.environ.get("AUTH_LDAP_SERVER_URI", "ldap://idm-dmz.dkrz.de")
AUTH_LDAP_START_TLS = bool(int(os.environ.get("AUTH_LDAP_START_TLS", "0")))
# The directory with SSL certificates
CA_CERT_DIR = str(web_config_path.parent)
Expand All @@ -191,16 +185,12 @@ def _set_favicon(html_color: str, project_root: Path) -> None:
}
# this is not used by django directly, but we use it for
# python-ldap access, as well.
LDAP_USER_BASE = os.environ.get(
"LDAP_USER_BASE", "cn=users,cn=accounts,dc=dkrz,dc=de"
)
LDAP_USER_BASE = os.environ.get("LDAP_USER_BASE", "cn=users,cn=accounts,dc=dkrz,dc=de")
LDAP_GROUP_BASE = os.environ.get(
"LDAP_GROUP_BASE", "cn=groups,cn=accounts,dc=dkrz,dc=de"
)

AUTH_LDAP_USER_SEARCH = LDAPSearch(
LDAP_USER_BASE, ldap.SCOPE_SUBTREE, "(uid=%(user)s)"
)
AUTH_LDAP_USER_SEARCH = LDAPSearch(LDAP_USER_BASE, ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
# keep the authenticated user for group search
AUTH_LDAP_BIND_AS_AUTHENTICATING_USER = True
if ALLOWED_GROUP != "*":
Expand All @@ -210,9 +200,7 @@ def _set_favicon(html_color: str, project_root: Path) -> None:
LDAP_FIRSTNAME_FIELD = os.environ.get("LDAP_FIRSTNAME_FIELD", "givenname")
LDAP_LASTNAME_FIELD = os.environ.get("LDAP_LASTNAME_FIELD", "sn")
LDAP_EMAIL_FIELD = os.environ.get("LDAP_EMAIL_FIELD", "mail")
LDAP_GROUP_CLASS = (
f'(objectClass={os.environ.get("LDAP_GROUP_CLASS", "groupOfNames")})'
)
LDAP_GROUP_CLASS = f'(objectClass={os.environ.get("LDAP_GROUP_CLASS", "groupOfNames")})'
LDAP_GROUP_TYPE = os.environ.get(
"LDAP_GROUP_TYPE", "nested"
) # accepted values: nested, posix
Expand Down Expand Up @@ -325,16 +313,14 @@ def _set_favicon(html_color: str, project_root: Path) -> None:
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
h.strip()
for h in os.environ.get("ALLOWED_HOSTS", "localhost,127.0.0.1")
for h in os.environ.get("ALLOWED_HOSTS", "localhost,127.0.0.1").split(",")
if h.strip()
]

# Provide a full list of all valid hosts (including the http(s):// prefix) which are expected
CSRF_TRUSTED_ORIGINS = [
h.strip()
for h in os.environ.get("CSRF_TRUSTED_ORIGINS", "http://localhost").split(
","
)
for h in os.environ.get("CSRF_TRUSTED_ORIGINS", "http://localhost").split(",")
if h.strip()
]

Expand Down

0 comments on commit 196cd3d

Please sign in to comment.