Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael William Coughlin
GraceDB Server
Commits
941a6d22
Commit
941a6d22
authored
6 years ago
by
Tanner Prestegard
Committed by
GraceDB
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Get ALLOWED_HOSTS and server FQDN from envvars for containerized service
parent
4a06c6b8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/settings/base.py
+1
-20
1 addition, 20 deletions
config/settings/base.py
config/settings/container.py
+25
-1
25 additions, 1 deletion
config/settings/container.py
config/settings/vm.py
+23
-2
23 additions, 2 deletions
config/settings/vm.py
with
49 additions
and
23 deletions
config/settings/base.py
+
1
−
20
View file @
941a6d22
...
...
@@ -12,10 +12,6 @@ PROJECT_ROOT = join(BASE_DIR, "gracedb")
# Other useful paths
PROJECT_DATA_DIR
=
join
(
BASE_DIR
,
"
..
"
,
"
project_data
"
)
# Server hostname and FQDN
SERVER_HOSTNAME
=
socket
.
gethostname
()
SERVER_FQDN
=
socket
.
getfqdn
()
# Unauthenticated access ------------------------------------------------------
# This variable controls whether unauthenticated access is allowed *ANYWHERE*
# on this service, except the home page, which is always public.
...
...
@@ -68,8 +64,7 @@ USE_TZ = True
# Allow this site to be served on localhost, the FQDN of this server, and
# hostname.ligo.org. Security measure for preventing cache poisoning and
# stopping requests submitted with a fake HTTP Host header.
ALLOWED_HOSTS
=
[
'
localhost
'
,
'
127.0.0.1
'
,
SERVER_FQDN
,
'
{0}.ligo.org
'
.
format
(
SERVER_HOSTNAME
)]
ALLOWED_HOSTS
=
[
'
localhost
'
,
'
127.0.0.1
'
]
# Sessions settings -----------------------------------------------------------
SESSION_COOKIE_AGE
=
3600
*
23
...
...
@@ -99,20 +94,6 @@ LVALERT_OVERSEER_PORTS = {
"
lvalert-test.cgca.uwm.edu
"
:
8001
,
}
# Email settings --------------------------------------------------------------
EMAIL_HOST
=
'
localhost
'
SERVER_EMAIL
=
'
GraceDB <gracedb@{fqdn}>
'
.
format
(
fqdn
=
SERVER_FQDN
)
ALERT_EMAIL_FROM
=
SERVER_EMAIL
ALERT_EMAIL_TO
=
[]
ALERT_EMAIL_BCC
=
[]
ALERT_TEST_EMAIL_FROM
=
SERVER_EMAIL
ALERT_TEST_EMAIL_TO
=
[]
# EMBB email settings
EMBB_MAIL_ADDRESS
=
'
embb@{fqdn}.ligo.org
'
.
format
(
fqdn
=
SERVER_FQDN
)
EMBB_SMTP_SERVER
=
'
localhost
'
EMBB_MAIL_ADMINS
=
[
admin
[
1
]
for
admin
in
ADMINS
]
EMBB_IGNORE_ADDRESSES
=
[
'
Mailer-Daemon@{fqdn}
'
.
format
(
fqdn
=
SERVER_FQDN
)]
# Access and authorization ----------------------------------------------------
# Some proper names related to authorization
LVC_GROUP
=
'
Communities:LSCVirgoLIGOGroupMembers
'
...
...
This diff is collapsed.
Click to expand it.
config/settings/container.py
+
25
−
1
View file @
941a6d22
...
...
@@ -5,6 +5,7 @@ import os
from
django.core.exceptions
import
ImproperlyConfigured
from
.base
import
*
# Get required variables from environment variables ---------------------------
# Get database password from environment and check
DB_PASSWORD
=
os
.
environ
.
get
(
'
DJANGO_DB_PASSWORD
'
,
None
)
if
DB_PASSWORD
is
None
:
...
...
@@ -15,12 +16,17 @@ SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', None)
if
SECRET_KEY
is
None
:
raise
ImproperlyConfigured
(
'
Could not get secret key from envvars.
'
)
# Get primary FQDN
SERVER_FQDN
=
os
.
environ
.
get
(
'
DJANGO_PRIMARY_FQDN
'
,
None
)
if
SERVER_FQDN
is
None
:
raise
ImproperlyConfigured
(
'
Could not get FQDN from envvars.
'
)
# Get Twilio account information from environment
# FIXME
TWILIO_ACCOUNT_SID
=
os
.
environ
.
get
(
'
DJANGO_TWILIO_ACCOUNT_SID
'
,
'
abcd
'
)
TWILIO_AUTH_TOKEN
=
os
.
environ
.
get
(
'
DJANGO_TWILIO_AUTH_TOKEN
'
,
'
abcd
'
)
# Database settings
# Database settings
-----------------------------------------------------------
DATABASES
=
{
'
default
'
:
{
'
NAME
'
:
'
gracedb
'
,
...
...
@@ -35,4 +41,22 @@ DATABASES = {
}
}
# Update allowed hosts from environment variables -----------------------------
hosts_from_env
=
os
.
environ
.
get
(
'
DJANGO_ALLOWED_HOSTS
'
,
None
)
if
hosts_from_env
is
not
None
:
ALLOWED_HOSTS
+=
hosts_from_env
.
split
(
'
,
'
)
ALLOWED_HOSTS
+=
[
SERVER_FQDN
]
# Email settings - dependent on server hostname and FQDN ----------------------
EMAIL_HOST
=
'
localhost
'
SERVER_EMAIL
=
'
GraceDB <gracedb@{fqdn}>
'
.
format
(
fqdn
=
SERVER_FQDN
)
ALERT_EMAIL_FROM
=
SERVER_EMAIL
ALERT_EMAIL_TO
=
[]
ALERT_EMAIL_BCC
=
[]
ALERT_TEST_EMAIL_FROM
=
SERVER_EMAIL
ALERT_TEST_EMAIL_TO
=
[]
# EMBB email settings
EMBB_MAIL_ADDRESS
=
'
embb@{fqdn}.ligo.org
'
.
format
(
fqdn
=
SERVER_FQDN
)
EMBB_SMTP_SERVER
=
'
localhost
'
EMBB_MAIL_ADMINS
=
[
admin
[
1
]
for
admin
in
ADMINS
]
EMBB_IGNORE_ADDRESSES
=
[
'
Mailer-Daemon@{fqdn}
'
.
format
(
fqdn
=
SERVER_FQDN
)]
This diff is collapsed.
Click to expand it.
config/settings/vm.py
+
23
−
2
View file @
941a6d22
# For running a VM that is provisioned by Puppet with
#
a secret.py file
for secret settings
# For running a VM that is provisioned by Puppet with
a secret.py file
# for secret settings
# Get secret settings:
# DEFAULT_DB_PASSWORD, DEFAULT_SECRET_KEY, TWILIO_ACCOUNT_SID,
# TWILIO_AUTH_TOKEN
from
.base
import
*
from
.secret
import
*
import
socket
# Nested dict of settings for all databases
DATABASES
=
{
...
...
@@ -22,3 +23,23 @@ DATABASES = {
# Secret key for a Django installation
SECRET_KEY
=
DEFAULT_SECRET_KEY
# Set up allowed hosts
SERVER_FQDN
=
socket
.
getfqdn
()
SERVER_HOSTNAME
=
socket
.
gethostname
()
ALLOWED_HOSTS
+=
[
SERVER_FQDN
,
'
{hostname}.ligo.org
'
.
format
(
hostname
=
SERVER_HOSTNAME
)]
# Email settings - dependent on server hostname and FQDN ----------------------
EMAIL_HOST
=
'
localhost
'
SERVER_EMAIL
=
'
GraceDB <gracedb@{fqdn}>
'
.
format
(
fqdn
=
SERVER_FQDN
)
ALERT_EMAIL_FROM
=
SERVER_EMAIL
ALERT_EMAIL_TO
=
[]
ALERT_EMAIL_BCC
=
[]
ALERT_TEST_EMAIL_FROM
=
SERVER_EMAIL
ALERT_TEST_EMAIL_TO
=
[]
# EMBB email settings
EMBB_MAIL_ADDRESS
=
'
embb@{fqdn}.ligo.org
'
.
format
(
fqdn
=
SERVER_FQDN
)
EMBB_SMTP_SERVER
=
'
localhost
'
EMBB_MAIL_ADMINS
=
[
admin
[
1
]
for
admin
in
ADMINS
]
EMBB_IGNORE_ADDRESSES
=
[
'
Mailer-Daemon@{fqdn}
'
.
format
(
fqdn
=
SERVER_FQDN
)]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment