Skip to content

Commit

Permalink
Merge branch 'master' into devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 committed Jan 10, 2024
2 parents a987c57 + ade8718 commit b5f74c7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/contributing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Contributing

on:
pull_request:

jobs:
validate-existing-contributors:
uses: ocadotechnology/codeforlife-workspace/.github/workflows/validate-existing-contributors.yaml@main
8 changes: 4 additions & 4 deletions deploy/middleware/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
class CustomSecurityMiddleware(SecurityMiddleware):
"""
Extends Django's Security Middleware.
See https://docs.djangoproject.com/en/2.2/_modules/django/middleware/security/ for
the source code, as well as https://docs.djangoproject.com/en/2.2/ref/middleware/#module-django.middleware.security
See https://docs.djangoproject.com/en/3.2/_modules/django/middleware/security/ for
the source code, as well as https://docs.djangoproject.com/en/3.2/ref/middleware/#module-django.middleware.security
for docs on security middleware.
"""

def process_response(self, request, response):
"""
Extends the original security middleware to ensure the X-XSS-Protection header
is set to 0.
is set to 1.
"""
super().process_response(request, response)

if self.xss_filter:
response["X-XSS-Protection"] = "0"
response["X-XSS-Protection"] = "1"

return response
1 change: 1 addition & 0 deletions example_project/portal_test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin"
CSRF_USE_SESSIONS = False # Setting to False to allow CSRF token to work in Cypress
RECAPTCHA_DOMAIN = "www.recaptcha.net"
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend", "portal.backends.StudentLoginBackend"]
USE_TZ = True
Expand Down
1 change: 1 addition & 0 deletions example_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin"
CSRF_USE_SESSIONS = True
RECAPTCHA_DOMAIN = "www.recaptcha.net"
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend", "portal.backends.StudentLoginBackend"]
USE_TZ = True
Expand Down
2 changes: 1 addition & 1 deletion portal/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "6.39.9"
__version__ = "6.39.10"
2 changes: 1 addition & 1 deletion portal/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_security_headers(self):
assert response.headers["cache-control"] == "private"
assert response.headers["x-content-type-options"] == "nosniff"
assert response.headers["x-frame-options"] == "DENY"
assert response.headers["x-xss-protection"] == "0"
assert response.headers["x-xss-protection"] == "1"


class TestSessionTimeoutMiddleware(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion run_testserver
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ set -e
cd "${BASH_SOURCE%/*}"

./example_project/manage.py collectstatic --noinput --clear
./example_project/manage.py testserver portal/tests/cypress/fixtures/teachersToBeDeleted.json
./example_project/manage.py testserver portal/tests/cypress/fixtures/teachersToBeDeleted.json --settings="portal_test_settings"

0 comments on commit b5f74c7

Please sign in to comment.