Harden the API and the data layer after a security and performance audit
Security - Every route now requires a login and refuses ids outside the caller's workspace with 404: plan, leave-wishes, day-overrides and vacation-days were fully anonymous; every other router trusted client-supplied workspace/child/parent ids. Scraper sessions are bound to their owner. - Invitations can no longer be created for a foreign workspace, and a redeemer who is already a member (or a full workspace) is refused. - Production refuses the default JWT secret; API docs are hidden in production; a failed migration aborts startup instead of serving. - Login and register no longer reveal whether an email exists; inactive accounts are rejected; /auth/refresh is rate limited. - The FK scraper writes debug artefacts only when explicitly enabled, logs no scraped values or page text, clears the BankID QR as soon as it is scanned and purges finished sessions after five minutes. - Real FK page captures are removed from the tree (history rewrite follows); the parser tests use a synthetic fixture. Performance and correctness - Plan apply/sync run inside one locked transaction with batched writes instead of one commit per row, so a failure mid-batch leaves nothing half-applied and concurrent syncs no longer corrupt each other. - SQLite runs in WAL mode with a busy timeout; 14 indexes cover the filters that were full scans; argon2 hashing runs off the event loop; responses are gzipped. - Frontend: a 401 now refreshes the token once and retries, so sessions no longer die silently after 15 minutes; every data hook discards stale responses; logout clears state even when the server call fails. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CsXCCcDfmV4Sps4ZQSvNEY
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Synthetic stand-in for a captured FK "#/valjdagar" page.
|
||||
|
||||
This is NOT a real Försäkringskassan page dump — it is a hand-built,
|
||||
minimal HTML fragment that reproduces only the DOM structure and CSS
|
||||
selectors that `app/scrapers/fk_scraper.py::_extract_parental_leave`
|
||||
reads (see `_SEL` in that module). All names, day counts, and amounts
|
||||
below are fictitious (see F1 of the scraper/config/ops security audit —
|
||||
the previous fixture was a real capture containing a developer's
|
||||
family's actual FK balances and was removed from the repo).
|
||||
-->
|
||||
<html lang="sv">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Ansök och planera föräldrapenning - Försäkringskassan (synthetic fixture)</title>
|
||||
</head>
|
||||
<body>
|
||||
<div data-test="forDig">
|
||||
<div class="f-panel">
|
||||
<div class="f-panel__header"><h4>För dig</h4></div>
|
||||
<div class="f-panel__body">
|
||||
<div class="visa-dagar" data-test="body">
|
||||
<div class="row">
|
||||
<div class="col col--sm-7 col--md-8" data-test="body">
|
||||
<div>
|
||||
<span class="visa-dagar__dagar-kvar">100</span>
|
||||
<span class="visa-dagar__discrete">av 240 dagar kvar efter ansökan</span>
|
||||
</div>
|
||||
<div class="visa-dagar__desktop">
|
||||
<div class="niva-statistik">
|
||||
<span class="niva-statistik__icon color-sjukpenning"></span>
|
||||
<div class="niva-statistik__text">
|
||||
<p>Sjukpenningnivå <span class="niva-statistik__dagar"><span class="">(60 dagar)</span></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="niva-statistik">
|
||||
<span class="niva-statistik__icon color-lagsta"></span>
|
||||
<div class="niva-statistik__text">
|
||||
<p>Lägstanivå <span class="niva-statistik__dagar"><span class="">(40 dagar)</span></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" data-test="footer">
|
||||
<div class="col col--sm-12 col--md-12"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-test="forDigOchAnnanForalder">
|
||||
<div class="f-panel">
|
||||
<div class="f-panel__header"><h4>Totalt för Testbarn</h4></div>
|
||||
<div class="f-panel__body">
|
||||
<p>Exempel på belopp: 1 234 kronor för 5 dagar.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="visa-dagar" data-test="dubbeldag">
|
||||
<div class="row">
|
||||
<div class="col col--sm-7 col--md-8" data-test="body">
|
||||
<div>
|
||||
<span class="visa-dagar__dagar-kvar">20</span>
|
||||
<span class="visa-dagar__discrete">av 60 dubbeldagar kvar efter ansökan</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" data-test="footer">
|
||||
<div class="col col--sm-12 col--md-12"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="button--primary">Ansök för Testbarn</button>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user