-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Updated settings.py to dynamically populate ALLOWED_HOSTS using domains from the Django sites. #1384
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
cf74c4f
to
e390966
Compare
This comment has been minimized.
This comment has been minimized.
lms/envs/production.py
Outdated
FEATURES['PREVIEW_LMS_BASE'], | ||
# Fetching all domain names from the Site model | ||
site_domains = [site.domain for site in Site.objects.all()] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amirtds We will also need to cover custom domains
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bryanlandia I think the Sites has the custom domain too. I checked cockroach labs domain and could find it there. If not we can load it from somewhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right, the code actually switches Site.domain to be university.cockroachlabs.com and then sets alt domain to the original Tahoe one, but it's good to cover both in case some custom JS or something somewhere still uses the orig .tahoe.appsembler.com domain
lms/envs/production.py
Outdated
@@ -27,7 +27,9 @@ | |||
import yaml | |||
from corsheaders.defaults import default_headers as corsheaders_default_headers | |||
from django.core.exceptions import ImproperlyConfigured | |||
from django.contrib.sites.models import Site |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will apps have loaded by this point? I don't think so. We might need to do this in in an app.ready()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bryanlandia Moved it to openedx -> core -> djangoapps -> appsembler -> sites -> apps.py. Let me know wdyt
This comment has been minimized.
This comment has been minimized.
8027cfc
to
cfdb47a
Compare
This comment has been minimized.
This comment has been minimized.
3731306
to
75d177d
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
75d177d
to
d345708
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change is also needed in cms/envs/production.py
and we could include the alternative domains
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Looks like the Docker build for checks is failing because py2neo is now End of Life and there are no longer any releases in GitHub for https://github.com/technige/py2neo We'll need to update in another PR first. Maybe been fixed upstream so will check |
Yes will cherrypick openedx@1db6867 |
Waiting on merge to main of #1387 |
5bebaf4
to
4d817ae
Compare
This comment has been minimized.
This comment has been minimized.
Hi @bryanlandia I added same settings for CMS as well, could you please take a look when you have some time |
This comment has been minimized.
This comment has been minimized.
…domains from the Django sites model
need to allow requests from customer custom domains
3c756b0
to
88217c3
Compare
Checking git merge conflicts against https://github.com/edx/edx-platform.git
|
Change description
We received a security report highlighting a Host Header Injection vulnerability due to the use of a wildcard '*' in our ALLOWED_HOSTS setting. This configuration could lead to open redirects and other security risks.
I have modified
settings.py
to dynamically construct theALLOWED_HOSTS
list using domain names from our Django sites to ensures that only valid domains are served.Changes:
ALLOWED_HOSTS
.ALLOWED_HOSTS
with domain names fetched from theSite
model.ENV_TOKENS['LMS_BASE']
andFEATURES['PREVIEW_LMS_BASE']
are included inALLOWED_HOSTS
if they are valid.ALLOWED_HOSTS
.Type of change
Related issues
Checklists
Development
Security
Code review