Commit Graph
23 Commits
Author SHA1 Message Date
finnandClaude Opus 5.5 cc3d064e64 Expire sessions after 30 min idle and 12 h absolute
Sessions were only bounded by a process restart or the LRU eviction, so
a stolen or fixed session id could stay valid for months. A cookie TTL
would not help, since an attacker with a copy of the id ignores it.

The store entry now carries _created_at and _last_seen (monotonic
time). They are kept out of the session dict as attributes of the
Session object, so is_empty() and the app code are unaffected.
open_session drops expired entries and returns a fresh, empty session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 11:46:44 +00:00
finnandClaude Opus 5.5 ca023e705c Invalidate sessions server-side on logout and deactivation
Session.clear() set the id to None before clearing, so on_update
assigned a new id and save_session deleted the store entry of that new
id. The entry of the old id with the user_id stayed valid: a copied
cookie survived the logout, and a session "logged out" by the auth
middleware for a disabled user was valid again after re-enabling.

- Session.clear() now removes the store entry of the current id.
- Deactivating a user removes all of their sessions immediately, like
  deleting a user does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 11:03:03 +00:00
finnandClaude Opus 5.5 dc85c578a2 Protect against login CSRF without cookies for anonymous users
Anonymous users must not get cookies or session store entries, so a
CSRF token for /login is not possible. Instead, every unsafe request is
checked statelessly via Sec-Fetch-Site, falling back to Origin. Requests
without both headers are not from a browser and are accepted. The
expected origin comes from the new MAX_ORIGIN setting, which is required
outside of debug mode.

Further CSRF changes:
- Do not delete the CSRF token on a failed check. It added no security,
  but invalidated forms in open tabs and could be triggered cross-site.
- Treat HEAD and OPTIONS as safe methods.

Keep the login page free of sessions:
- Show login messages via ?msg=login_required|logout (fixed keys only)
  and the login error via the template context instead of flash().
- Only send the session deletion cookie if the client sent a cookie.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 11:03:03 +00:00
finnandClaude Opus 5.5 91e95b1947 Make isort compatible with black
isort's lines_after_imports = 2 conflicted with black, so run-cleanup
reverted black's changes. Use isort's black profile instead and apply the
resulting formatting. Also fix the flake8 errors in check_email_mixin and
drop a leftover debug print.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:06:51 +00:00
finnandClaude Opus 5.5 340006ff37 Disable debug default login
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 08:39:28 +00:00
finnandClaude Opus 5.5 86fcdfde27 Devcontainer: enable bash-completion and set UTF-8 locale
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 08:39:28 +00:00
finnandClaude Opus 5.5 e0b5e05cce Use port 8757 for the dev server
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 08:39:28 +00:00
finnandClaude Opus 5.5 9f25457b24 Remove old docker-compose based dev setup
The devcontainer replaces Dockerfile.dev, dc.dev.yml and the related
start/entrypoint scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 08:39:28 +00:00
finnandClaude Opus 5.5 9895017385 Restructure scripts into dev/ and prod/ for the devcontainer
- scripts/prod: entrypoint, db-setup and schema.sql shipped in the image
- scripts/dev: seed/clear db, psql and cleanup, run natively in the
  devcontainer instead of via docker-compose
- move setup.cfg to the repo root so linters pick it up
- Makefile targets run directly in the devcontainer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 08:39:28 +00:00
finnandClaude Opus 5.5 7c2b9fb3f4 Refactor logging and drop deprecated FLASK_ENV
Move logging setup into max/log.py. The file handler is only used outside
debug mode and its directory is configurable via LOG_DIR. FLASK_ENV is
deprecated in Flask; debug mode is now controlled via FLASK_DEBUG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 08:21:07 +00:00
finn 65dddea3bc initial switch to a devcontainer 2026-10-21 06:25:18 +00:00
finn 2bd853e9b5 modernizing the dependencies 2026-10-19 18:53:59 +02:00
Finn Stutzenstein a1c6b656d7 multi-domain support 2022-03-15 18:36:41 +01:00
Finn Stutzenstein 58f46d0bbe Fix typo 2022-03-12 08:38:42 +01:00
Finn Stutzenstein 7124133f88 Fix SQL queries and order tables 2022-03-06 11:22:45 +01:00
Finn Stutzenstein 818a43202a remove can_receive 2022-03-06 11:14:19 +01:00
Finn Stutzenstein 8f623a264d Fix user creation 2022-03-06 10:01:17 +01:00
Finn Stutzenstein d7641c2da4 Fix SQL queries 2022-03-06 09:53:34 +01:00
Finn Stutzenstein b31f83e214 Fix prod docker file 2022-03-06 09:39:06 +01:00
Finn Stutzenstein aff7bf3b48 Unique emails and added can_receive 2022-03-06 09:34:23 +01:00
Finn Stutzenstein ba580483b4 Fix real ip header 2022-02-01 18:35:41 +01:00
Finn Stutzenstein add153d8a6 More work 2022-01-22 18:37:56 +01:00
FinnStutzenstein 9d018e00be initial commit 2020-04-13 08:31:44 +02:00