Skip to content
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

Adds dc utils and basic auth middleware #2440

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ django-dotenv==1.4.2
django-extensions==3.2.1
django-filter==23.1
django-model-utils==4.3.1
django-pipeline==2.1.0
django-pipeline==3.0.0
django-sesame==3.2.2
django-storages==1.13.2
django-svelte==0.2.1
Expand Down Expand Up @@ -97,3 +97,4 @@ WebTest==3.0.0
whitenoise==6.5.0
Whoosh==2.7.4
yanc==0.3.3
git+https://github.com/DemocracyClub/[email protected]
7 changes: 7 additions & 0 deletions ynr/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def root(*path):
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"candidates.middleware.DisableCachingForAuthenticatedUsers",
"wombles.middleware.CheckProfileDetailsMiddleware",
"dc_utils.middleware.BasicAuthMiddleware",
)

AUTHENTICATION_BACKENDS = (
Expand Down Expand Up @@ -501,3 +502,9 @@ def _is_running_tests():
from .testing import * # noqa
else:
RUNNING_TESTS = False

# Allowlist of URLs that should be ignored by dc_utils BasicAuthMiddleware
BASIC_AUTH_ALLOWLIST = [
"/api",
"/api/*",
Copy link
Member

@chris48s chris48s Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being an EC2-based app, YNR does have a healthcheck endpoint.

Annoyingly the load balancer just calls / rather than a dedicated endpoint so we would need to allow that but if we deployed this as-is, we'd go into a loop of:

  • bring up a new instance
  • the load balancer decides it is unhealthy and shuts it down
  • bring up a new instance

..and so on.

Given we are probably parking this until we actually have a staging site, maybe lets not not bogged down but I did just want to note that here.

]