Skip to content

Commit

Permalink
bug-1898800: fix csrf token storage
Browse files Browse the repository at this point in the history
This changes Crash Stats to store the csrf token in the session rather
than in the cookie.

This also adjusts the order of the middleware per Django's documented
conventions.
  • Loading branch information
willkg committed May 28, 2024
1 parent 4ef8372 commit f88b8d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions webapp/crashstats/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ def path(*dirs):
# CORS needs to go before other response-generating middlewares
"corsheaders.middleware.CorsMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"crashstats.tokens.middleware.APIAuthenticationMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"mozilla_django_oidc.middleware.SessionRefresh",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
# If you run crashstats behind a load balancer, your `REMOTE_ADDR` header
# will be that of the load balancer instead of the actual user. The
Expand Down Expand Up @@ -491,6 +491,7 @@ def filter(self, record):
)

CSRF_COOKIE_NAME = "crashstatscsrfcookie"
CSRF_USE_SESSIONS = True

SESSION_COOKIE_SECURE = _config(
"SESSION_COOKIE_SECURE",
Expand Down

0 comments on commit f88b8d7

Please sign in to comment.