Commit Graph

6 Commits

Author SHA1 Message Date
muena
02a4ed551b Anmeldung ausschliesslich ueber Entra ID
Entfernt die Anmeldung mit Passwort restlos: Anbieter in auth.ts,
Server Actions, Anmeldeformular und Passwortwechsel-Seite, die Umleitung im
Layout, den Status passwort_wechseln, die Typen, und die beiden
Migrationen 20260908120000 und 20260908140000. Die dort ebenfalls
angelegten Funktionen app_zugang_setzen und app_benutzer_liste hatten
keine Oberflaeche; der HR-Zugang wird ueber freischalten.ps1 vergeben.

20261014120000_anmeldung_nur_ueber_entra.sql entfernt die Objekte aus
einer Datenbank, die sie noch enthaelt, und setzt is_hr_user() auf die
Fassung ohne Passwortbezug. Auf einer neuen Installation bewirkt sie
nichts.

Zusatz-Branch fuer den Uebergabestand (uebergabe/README.md): bleibt ein
einzelner Commit auf master, bis der Testbetrieb die Passwortanmeldung
nicht mehr braucht; danach in master mergen.

Geprueft: frische Installation (113 Migrationen, zweiter Lauf leer,
rauchtest und vertragsangaben bestanden, keine Passwortobjekte) und
Upgrade einer master-Datenbank (Passwortobjekte entfernt, is_hr_user ohne
Passwortbezug); lint, tsc, types:check, 823 Unit-Tests, Waechter.
2026-11-11 14:10:02 +01:00
muena
86177d648e Uebergabe-Bereinigung: Kommentare, Geheimnisse, CSP, Dokumentation
Kommentare beschreiben den heutigen Stand und warum er so ist, nicht mehr
die Entwicklungsgeschichte: keine Datumsangaben zu Ereignissen, keine
Vorfaelle an Testpersonen, keine Lieferantensicht, keine internen Namen
oder Plattformen. In Migrationen nur Kommentare ausserhalb von
Dollar-Quoting; Kommentare in Funktionskoerpern nur dort, wo ihr Text in
keiner anderen Migration als Anker vorkommt.

- Andreis Anpassungen aus windows-uebergabe nach master uebernommen.
- LOLYO-Startpasswort kommt aus LOLYO_STARTPASSWORT statt aus dem Code;
  ohne Wert lehnt der Export mit Hinweis ab.
- Beispiel- und erzeugte E-Mail-Adressen ohne Kundendomain.
- Content-Security-Policy wird durchgesetzt; form-action fest mit
  login.microsoftonline.com, weil das Paket ohne Umgebungswerte gebaut
  wird. Geprueft im Browser: alle Seiten ohne Verstoss, Weiterleitung zu
  Microsoft geht durch.
- migrate.mjs: einmalige Uebernahme der alten Buchfuehrung entfernt (seit
  20260907100000 ohne Wirkung).
- freischalten.ps1 vergibt und entzieht den HR-Zugang (-Entziehen) und
  protokolliert beides im Audit-Log.
- docs/security-review.md -> docs/sicherheitskonzept.md: beschreibt den
  heutigen Stand ohne offene Punkte. README, entra-sso.md und
  deploy/windows/README.md ohne Widersprueche (Leserolle der IT,
  Freischaltung, Konto des Nachtlaufs), Abnahme-Checkliste statt
  "noch offen".

Geprueft: lint, tsc, types:check, 823 Unit-Tests, Waechter (412 Dateien,
keine Funde), alle 114 Migrationen auf leerem PostgreSQL 18 (zweiter Lauf
leer), rauchtest.sql und vertragsangaben.sql bestanden.
2026-10-14 09:42:51 +02:00
47db290821 Kommentare ohne Namen, Daten und Verweise nach innen
Vorbereitung der Uebergabe. Die Begruendungen bleiben vollstaendig stehen --
sie sind der Wert dieser Kommentare; entfernt ist nur, woher sie stammen.

  "Gemeldet von <Name> am <Datum>: eine halb ausgefuellte Verteilung
   sieht aus wie eine Angabe"
  -> "Eine halb ausgefuellte Verteilung sieht aus wie eine Angabe"

Betroffen: 27 Namensnennungen in 21 Dateien, Verweise auf ein internes
Testprotokoll (B.02, C.08, D.06, E.07, H.05, H.06, N.02), Datumsangaben, die
eine Chronik der Defekte ergeben, und drei Verweise auf eine Datei, die nicht
mitgeht. Datumsangaben als *Daten* bleiben: die Excel-Epoche, die Beispiele
zur Datumserkennung, die Fixtures in den Tests.

Zwei Funde nebenbei:

actions/auth.ts beschrieb chk_passwort_pfad_endet als geltende Bedingung --
20260908140000 hat sie entfernt. Der Kommentar sagte seither das Gegenteil
dessen, was im Schema steht.

tests/unit/reports.test.ts gruppierte nach "Suesswaren", einem Wert, den
20261007090000 abgeschafft hat. Der Test war gruen, weil groupKeyFor nur
durchreicht -- er prueft jetzt einen Wert, den es gibt.

README verspricht kein npm run test:e2e mehr: weder Skript noch Playwright
sind vorhanden.
2026-10-13 17:33:19 +02:00
c6cff9656e Passwort-Anmeldung: Provider, Formulare, drei Zustaende der Shell
Some checks failed
CI / Lint, Typen, Tests, Build (push) Failing after 5m27s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m3s
2026-09-08 16:51:14 +02:00
4d8e3f7154 Restore the shapes the application was written against
The app runs against a real database for the first time since the port, and
two things were broken. Both were invisible to typecheck, lint, 192 tests
and the build.

Sign-in looped. Auth.js created the session and app_upsert_user() adopted
the existing profiles id correctly — the row was in app_users, right id and
all — but the proxy builds its own Auth.js instance from lib/auth/config.ts
alone, and the session callback that copies token.uid onto session.user.id
lived in auth.ts. So the proxy saw a session without an id, treated every
signed-in user as signed out, and sent them back to /login. Click, flash,
login page: from the outside it looked like the button did nothing.

The callback moves to the config both instances share. auth.ts now spreads
the base callbacks instead of replacing them, which is the mistake that
would reintroduce this.

The proxy test did not catch it because its fixture hands the handler a
session that already has user.id — it tested the routing, not the shape
Auth.js actually produces.

Then the dashboard crashed on a.date.localeCompare. PostgREST returned JSON:
a `date` arrived as "2026-08-03", a `numeric` as a number, and that is what
lib/supabase/types.ts declares and what every sort, every date comparison
and every status derivation assumes. The pg driver does the opposite — Date
object and string respectively. The declarations stayed true to what the
code believes; only the runtime value changed, which is why nothing flagged
it.

The driver is configured back to the declared shapes in lib/db/pool.ts,
rather than rewriting 49 call sites. That also removes a timezone hazard:
`date` is a calendar day, and as a Date object it acquires midnight in the
server's zone — a birth date would shift by a day in Austria, always. The
same class of bug as in the seed.

int8 stays a string on purpose: it only comes from count() and is read
through Number() everywhere; parsed as a number it would quietly lose
precision past 2^53.

A missing sign-in error now reaches the server log. Auth.js was failing
silently — a 302 back to /login and nothing to read. That was its own
defect, and it is the reason the first diagnosis took as long as it did.

Verified against the live database: all six pages render, 797 active of
852 records, 744.4 FTE, and a detail page shows birth date 15.08.1968
against SV number 7960 150868 — the digits agree, so no day has shifted.
Both new tests were checked by mutation: remove the fix and they fail.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 10:11:34 +02:00
2ba9b37aa7 Hand the front door to Entra, and keep the keys out of the build
Auth.js replaces GoTrue. The sign-in still goes to the same Entra tenant,
but nothing sits between the app and the identity provider any more — the
code exchange, state, nonce and the session cookie are ours.

lib/auth/session.ts stays the only place that knows where a user id comes
from, which is why this was one file and not fifty. What it returns is now
app_users.id. app_upsert_user() maps the Entra `oid` onto it, and for an
address that already has a profiles row it adopts that id instead of
minting a new one — otherwise everyone would have been signed in and cut
off from their own notes, drafts and audit trail at the same time.

That upsert is the one write that cannot have a session context yet: the
id is what it produces. It runs as a SECURITY DEFINER function that may
touch app_users and nothing else, which is a far smaller lever than the
service key that used to answer this class of problem.

The proxy no longer checks HR rights. It has no database connection, and
putting role/is_active in the token would have frozen the claim until the
next sign-in. The check moved to where it can read the current truth: the
app layout on every render, requireHrUser() for the export routes, and
underneath both, RLS.

Two things only came out by running it:

  - `export const proxy = auth(…)` is not a function declaration, so
    Next.js never found it and every request 404'd. `next build` reported
    success and listed the proxy. In the function config form auth() also
    returns the handler as a promise, so it needs an await. The proxy test
    now mocks it as a promise for that reason — a friendlier mock would
    let the same bug back in.

  - A missing AUTH_MICROSOFT_ENTRA_ID_ISSUER silently falls back to
    /common/, and the redirect really did go there. That would let any
    Microsoft account sign in, including a private one, and it would never
    look broken. It now refuses to start in production.

Neither build nor image needs credentials any more: the pool is created on
first use, the auth config is evaluated per request, and there are no
NEXT_PUBLIC_* values left to bake in. One image now runs in every
environment.

Verified: typecheck, lint, 187 tests, build, and by hand in the browser —
/employees redirects to /login, and the sign-in button reaches the Entra
page with PKCE and the callback URL that goes into the app registration.
Not verified against a real database; there is still no DATABASE_URL.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-31 14:57:32 +02:00