Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
AURA
steering
Commits
a2f77ab9
Verified
Commit
a2f77ab9
authored
7 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: read CORS_ALLOWED_ORIGINS, SITE_URL & LOGGING_JSON from the env
parent
94438c48
No related branches found
No related tags found
No related merge requests found
Pipeline
#8415
passed
7 months ago
Stage: check
Stage: test
Stage: build
Stage: deploy
Stage: release
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
steering/settings.py
+36
-25
36 additions, 25 deletions
steering/settings.py
with
36 additions
and
25 deletions
steering/settings.py
+
36
−
25
View file @
a2f77ab9
import
json
import
os
import
os
import
sys
import
sys
from
pathlib
import
Path
from
pathlib
import
Path
...
@@ -26,7 +27,10 @@ SITE_ID = 1
...
@@ -26,7 +27,10 @@ SITE_ID = 1
# Must be set if DEBUG is False
# Must be set if DEBUG is False
ALLOWED_HOSTS
=
os
.
getenv
(
"
ALLOWED_HOSTS
"
,
default
=
"
127.0.0.1,localhost
"
).
split
(
"
,
"
)
ALLOWED_HOSTS
=
os
.
getenv
(
"
ALLOWED_HOSTS
"
,
default
=
"
127.0.0.1,localhost
"
).
split
(
"
,
"
)
CORS_ALLOWED_ORIGINS
=
[
"
http://localhost:8080
"
,
"
http://localhost:8040
"
]
CORS_ALLOWED_ORIGINS
=
os
.
getenv
(
"
CORS_ALLOWED_ORIGINS
"
,
default
=
"
http://localhost:8080,http://localhost:8040
"
,
).
split
(
"
,
"
)
CORS_ALLOW_CREDENTIALS
=
True
CORS_ALLOW_CREDENTIALS
=
True
CORS_ALLOW_HEADERS
=
list
(
default_headers
)
+
[
CORS_ALLOW_HEADERS
=
list
(
default_headers
)
+
[
"
content-disposition
"
,
"
content-disposition
"
,
...
@@ -206,7 +210,10 @@ AURA_PROTO = os.getenv("AURA_PROTO", default="http")
...
@@ -206,7 +210,10 @@ AURA_PROTO = os.getenv("AURA_PROTO", default="http")
AURA_HOST
=
os
.
getenv
(
"
AURA_HOST
"
,
default
=
"
localhost
"
)
AURA_HOST
=
os
.
getenv
(
"
AURA_HOST
"
,
default
=
"
localhost
"
)
# SITE_URL is used by django-oidc-provider and openid-configuration will break if not set correctly
# SITE_URL is used by django-oidc-provider and openid-configuration will break if not set correctly
SITE_URL
=
f
"
{
AURA_PROTO
}
://
{
AURA_HOST
}
:
{
PORT
}
"
if
PORT
else
f
"
{
AURA_PROTO
}
://
{
AURA_HOST
}
"
SITE_URL
=
os
.
getenv
(
"
SITE_URL
"
,
default
=
f
"
{
AURA_PROTO
}
://
{
AURA_HOST
}
:
{
PORT
}
"
if
PORT
else
f
"
{
AURA_PROTO
}
://
{
AURA_HOST
}
"
,
)
if
AURA_PROTO
==
"
https
"
:
if
AURA_PROTO
==
"
https
"
:
CSRF_TRUSTED_ORIGINS
=
[
f
"
{
AURA_PROTO
}
://
{
AURA_HOST
}
"
]
CSRF_TRUSTED_ORIGINS
=
[
f
"
{
AURA_PROTO
}
://
{
AURA_HOST
}
"
]
...
@@ -215,31 +222,35 @@ OPERATION_MODE_TYPE = Literal["default", "tests"]
...
@@ -215,31 +222,35 @@ OPERATION_MODE_TYPE = Literal["default", "tests"]
OPERATION_MODE
:
OPERATION_MODE_TYPE
OPERATION_MODE
:
OPERATION_MODE_TYPE
OPERATION_MODE
=
cast
(
OPERATION_MODE_TYPE
,
os
.
getenv
(
"
OPERATION_MODE
"
,
default
=
"
default
"
))
OPERATION_MODE
=
cast
(
OPERATION_MODE_TYPE
,
os
.
getenv
(
"
OPERATION_MODE
"
,
default
=
"
default
"
))
LOGGING
=
{
# TODO: find a better way. This is limited to settings that can be JSON-encoded.
"
version
"
:
1
,
if
"
LOGGING_JSON
"
in
os
.
environ
:
"
disable_existing_loggers
"
:
False
,
LOGGING
=
json
.
loads
(
os
.
getenv
(
"
LOGGING_JSON
"
))
"
formatters
"
:
{
else
:
"
django.server
"
:
{
LOGGING
=
{
"
()
"
:
"
django.utils.log.ServerFormatter
"
,
"
version
"
:
1
,
"
format
"
:
"
[{server_time}] {message}
"
,
"
disable_existing_loggers
"
:
False
,
"
style
"
:
"
{
"
,
"
formatters
"
:
{
}
"
django.server
"
:
{
},
"
()
"
:
"
django.utils.log.ServerFormatter
"
,
"
handlers
"
:
{
"
format
"
:
"
[{server_time}] {message}
"
,
"
file
"
:
{
"
style
"
:
"
{
"
,
"
class
"
:
"
logging.FileHandler
"
,
}
"
filename
"
:
os
.
path
.
abspath
(
os
.
path
.
join
(
BASE_DIR
,
"
logs
"
,
"
steering.log
"
)),
"
formatter
"
:
"
django.server
"
,
},
},
},
"
handlers
"
:
{
"
loggers
"
:
{
"
file
"
:
{
"
django
"
:
{
"
class
"
:
"
logging.FileHandler
"
,
"
handlers
"
:
[
"
file
"
]
,
"
filename
"
:
os
.
path
.
abspath
(
os
.
path
.
join
(
BASE_DIR
,
"
logs
"
,
"
steering.log
"
))
,
"
level
"
:
os
.
getenv
(
"
STEERING_LOG_LEVEL
"
,
"
INFO
"
)
,
"
formatter
"
:
"
django.server
"
,
"
propagate
"
:
True
,
}
,
},
},
},
"
loggers
"
:
{
}
"
django
"
:
{
"
handlers
"
:
[
"
file
"
],
"
level
"
:
os
.
getenv
(
"
STEERING_LOG_LEVEL
"
,
"
INFO
"
),
"
propagate
"
:
True
,
},
},
}
# ATTENTION:
# ATTENTION:
# Don’t add any configuration settings after this, so that administrators can override them.
# Don’t add any configuration settings after this, so that administrators can override them.
...
...
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