Use encrypted cookie instead of session for oauth state data
authorMagnus Hagander <magnus@hagander.net>
Wed, 11 Jun 2025 13:38:06 +0000 (15:38 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 11 Jun 2025 18:34:09 +0000 (20:34 +0200)
commiteb629db5838fcfc6ecec50d2b7556f9e65877cbd
tree15647ae0ef49f9de15d7b1f8946fbe8d13b4e03b
parente001690d4d966ab539f4bf5dd0b077371ba27c01
Use encrypted cookie instead of session for oauth state data

During oauth logins we need to store some temporary data related to the
users session. Previously we did this in the django session, but thanks
to AI bots trying millions of logins every day (and never completing the
process) we end up with many abandoned sessions in the db. To work
around this, instead store the temporary data in an encrypted cookie
passed to the browser. Since this cookie can be limited in scope to just
the auth part of the site, the slightly larger cookie size doesn't
matter, and we don't need to store any data at all server-side.
pgweb/account/oauthclient.py
pgweb/account/views.py