DemocracyClub / dc_django_utils

Shared helpers and utility functions for DC websites
MIT License
0 stars 2 forks source link

Basic auth middleware #86

Closed symroe closed 2 months ago

symroe commented 2 months ago

Basic auth middleware that's enabled if it thinks it's in the correct DC environment.

This will globally restrict the site. I think we might want an allow list for some paths in future (e.g, an API endpoint that already has authentication on it), but this is a decent MVP I think.

chris48s commented 2 months ago

I think we do need the allow list for MVP. As well as API endpoints, you also need to be able to disable this on whatever URL the load balancer uses for its health check endpoint.

Otherwise

..and now you're in a reboot loop.

Some other things to consider:

Some older DC apps still have some residual code knocking about from before when we did this with django-basicauth. For example:

I think it is reasonable to implement this as a shared middleware in dc_django_utils to standardise it, but when we roll it out we need to be conscious to do the necessary cleanup as part of that job.

symroe commented 2 months ago

Yeah, good point. Added in a new commit,

chris48s commented 2 months ago

Build is failing due to lint errors and I've suggested one more test case. Once you've done those two, I reckon it is good to merge :+1:

symroe commented 2 months ago

Thanks, both done. I'll wait for the build and then merge and publish a new release