mirror of
https://github.com/barkeser2002/offline-db.git
synced 2026-09-25 01:40:07 +03:00
- Add `Referrer-Policy` and `Permissions-Policy` headers to improve security.
- Add view caching for `AnimeViewSet`, `HomeViewSet`, and `UserBadgeViewSet`.
- Include `vary_on_headers('Authorization', 'Cookie')` for `UserBadgeViewSet` to prevent cross-user data leakage.
- Update `content/tests/test_performance.py` assertions to reflect cached responses.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Senpai-YoloBot <41898282+github-actions[bot]@users.noreply.github.com>
10 lines
389 B
Python
10 lines
389 B
Python
from django.utils.deprecation import MiddlewareMixin
|
|
|
|
class SecurityHeadersMiddleware(MiddlewareMixin):
|
|
def process_response(self, request, response):
|
|
# Adding Permissions-Policy header
|
|
response['Permissions-Policy'] = "camera=(), microphone=(), geolocation=()"
|
|
|
|
# Let Django SecurityMiddleware handle HSTS if SECURE_HSTS_SECONDS is set
|
|
return response
|