docs: record auth hash alignment and validation results
This commit is contained in:
1 parent
22887fef03
commit
f7819904b9
51 files changed
+1792
-542
No files matched your search
+6
-6
@@ -3,11 +3,11 @@
|
||||
- **Project:** shared
|
||||
- **Path:** /workspace/Personal/Web/shared
|
||||
- **Analyzed:** 2026-10-16
|
||||
- **Commit:** 5216031 on main
|
||||
- **Working tree:** 9 uncommitted change(s): `.changeset/user-management-roles.md` and `packages/web-ui/src/lib/components/UserManagement.svelte` deleted; `.changeset/remove-user-management.md` untracked; `README.md`, `MediaPlayerControls.svelte`, `packages/web-ui/src/lib/index.ts`, `packages/web-ui/src/lib/styles.css`, `packages/web-ui/src/lib/types.ts`, `shared-styles.css` modified. Findings reflect the working tree (for example, README component count, Q-014).
|
||||
- **Commit:** 22887fe on main
|
||||
- **Working tree:** Contains uncommitted changes from the earlier finding pass and this continuation; no changes have been committed.
|
||||
- **Stack:** Go 1.25 (`backend/`); Node.js ESM with `pg` (`packages/node-backend`); Python 3.10+ with asyncpg, bcrypt and optional FastAPI (`packages/python-backend`, ruff configured); Java 8 target with Jackson and JUnit 5 (`packages/java-backend`); Svelte 5 and TypeScript with svelte-check (`packages/web-ui`); PowerShell and Node build and sync scripts; Gitea and GitHub Actions.
|
||||
- **Scope:** A shared library consumed by other projects as a vendored snapshot. Read: root manifests and changesets, `.github` and `.gitea` workflows, `.githooks`, `scripts/` (sync, build, and the `scripts/media` tooling), all four language packages (AuthGuard clients, stores, TOTP, config, coreconfig, proxies), Go packages under `backend/` (auth read in a separate pass), and the web-ui library source (barrel, styles, primary-color, notifications, components that do I/O or timers). Excluded: `node_modules`, `packages/web-ui/dist` and `.svelte-kit` (gitignored, not tracked), `package-lock.json` and `go.sum` (versions only), and test bodies except for coverage notes. Backend findings come from read-only static review passes; the highest-impact citations were re-checked in the code. No lint, build or test was executed.
|
||||
- **Updated:** 2026-10-19 — Medium findings handled in the working tree (not committed): Q-004 and Q-009 fixed; Q-008 stays open for the cross-runtime hash-format decision.
|
||||
- **Scope:** A shared library consumed by other projects as a vendored snapshot. Read: root manifests and changesets, `.github` and `.gitea` workflows, `.githooks`, `scripts/` (sync, build, and the `scripts/media` tooling), all four language packages (AuthGuard clients, stores, TOTP, config, coreconfig, proxies), Go packages under `backend/` (auth read in a separate pass), and the web-ui library source (barrel, styles, primary-color, notifications, components that do I/O or timers). Excluded: `node_modules`, `packages/web-ui/dist` and `.svelte-kit` (gitignored, not tracked), `package-lock.json` and `go.sum` (versions only), and test bodies except for coverage notes. Backend findings came from read-only static review passes; the highest-impact citations were re-checked in the code. The shared Node, Python, web-ui and Go suites/checks, web-ui package build and checks were run during this continuation; Java tools remain unavailable.
|
||||
- **Updated:** 2026-10-20 — Q-008 fixed in the working tree: all password writers use bcrypt cost 12, legacy PBKDF2 verifies and upgrades after a successful login, and shared contract fixtures cover all runtimes. Node tests, web-ui tests, package build, Svelte check and Node syntax check passed.
|
||||
|
||||
## Summary
|
||||
|
||||
@@ -77,7 +77,7 @@ The code is generally tidy: no TODO, FIXME or HACK markers in first-party non-te
|
||||
- **Description:** Node and Python write incompatible hash formats into the same column, so a database shared between them cannot be verified by both. Python's list and create paths return the hash in their payloads; Node's do not. Java's middleware lets an unchecked exception escape where Node returns 401. The startup retry policy differs, so Python retries forever on errors that Node would surface immediately.
|
||||
- **Impact:** A service behaves differently depending on which runtime serves it, and a password hash can reach an API response in Python.
|
||||
- **Recommendation:** Standardise the hash format (or rehash on login), strip `password_hash` from every DTO, align the retry policy and the middleware failure modes, and add cross-language contract tests that run the same fixtures against each client.
|
||||
- **Status:** Open 2026-10-19 — partly fixed: Python list and create payloads no longer return `password_hash`, Python startup retries only transient connection errors like Node, the Java middleware answers 401 when no base URL is set, and Java `Totp` compares with `MessageDigest.isEqual`. Node, Python and Go version their password hashes and rewrite older ones on login (see S-013). New in this pass: `contract/auth-contract.json` holds shared fixtures (password hashes per runtime, RFC 6238 TOTP cases, client-address cases) that the Go, Node and Python suites all load (`backend/auth/contract_test.go`, `packages/node-backend/test/contract.test.js`, `packages/python-backend/tests/test_contract.py`); it records the remaining hash divergence on purpose. Running it found Python `verify_totp` raising `TypeError` on a six-digit token written in non-ASCII digits where Go and Node answer false, fixed in `totp.py`. The Node and Python stores now share Go's guards (see S-016), and Python refuses passwords over 72 bytes like Go. Still open: Node (PBKDF2) writes a different hash format into `auth_users.password_hash` than Python and Go (bcrypt); Node cannot verify bcrypt, and Python and Go cannot verify Node's. Decision needed: pick one write scheme for all runtimes (or accept a new bcrypt dependency in Node), because letting one runtime verify another's format would make a shared database ping-pong between schemes on re-key. The Java client is not in the contract tests: no JDK or Maven is available here to compile them. Files: `contract/auth-contract.json`, `backend/auth/contract_test.go`, `packages/node-backend/test/contract.test.js`, `packages/python-backend/tests/test_contract.py`, `packages/python-backend/src/shared_backend/totp.py`, `packages/python-backend/src/shared_backend/auth.py`, `packages/python-backend/src/shared_backend/postgres.py`, `packages/java-backend/src/main/java/com/gabriel20xx/shared/auth/AuthClient.java`, `packages/java-backend/src/main/java/com/gabriel20xx/shared/auth/Totp.java`, `packages/node-backend/src/auth.js`, `backend/auth/password.go`.
|
||||
- **Status:** Fixed 2026-10-20 — Node now writes the same prefixed bcrypt cost-12 scheme as Go and Python, and each runtime verifies current/legacy bcrypt plus both legacy Node PBKDF2 formats. Successful legacy verification returns an upgraded hash; AuthGuard conditionally persists that upgrade after a successful login. Long legacy PBKDF2 passwords use the explicit `bcrypt-sha256$` scheme to avoid bcrypt truncation, while new passwords over 72 bytes are rejected. The Java AuthClient does not create or verify stored password hashes. Node also depends on `bcryptjs` to share the scheme. The shared contract covers current, low-cost, malformed, legacy and over-limit cases. Files: `backend/auth/password.go`, `backend/auth/contract_test.go`, `Central/AuthGuard/internal/httpapi/{auth.go,server.go,server_test.go}`, `packages/node-backend/{package.json,src/auth.js,test/auth.test.js,test/contract.test.js}`, `packages/python-backend/src/shared_backend/auth.py`, `packages/python-backend/tests/{test_core.py,test_contract.py}`, `contract/auth-contract.json`.
|
||||
|
||||
### Q-009 · The Node and web-ui code has no linter, formatter or component tests · **Medium** · Fixed
|
||||
- **Location:** `.github/workflows/lint.yml` (Node job runs `npm run lint`, which is svelte-check and `node --check` only), `scripts/media/lint-all.mjs:57-64` (expects ESLint and Prettier configs in a package that does not have them), `packages/web-ui/` (no test files and no test script), `packages/node-backend/package.json` (no lint script)
|
||||
@@ -132,6 +132,6 @@ The code is generally tidy: no TODO, FIXME or HACK markers in first-party non-te
|
||||
- **Checked, clean:** No `TODO`, `FIXME`, `HACK` or `XXX` markers in first-party non-test code. No `any`, `@ts-ignore`, `@ts-expect-error` or `svelte-ignore` in `packages/web-ui/src`. No `{@html}`, `innerHTML`, `eval` or `new Function` in the web-ui or scripts. External links use `rel="noreferrer"`. Timers and document listeners are cleaned up in `StatusWidget`, `MediaPlayer`, `MediaPlayerControls`, `PrimaryColorPicker` and `notifications.svelte.ts`.
|
||||
- **Checked, consistent:** Go code is gofmt-checked and `go vet`-checked in CI. Python code is ruff-checked (`E`, `F`, `I`). Node syntax is checked for `packages/node-backend`. Parameterised SQL is used across the Go, Node and Python stores.
|
||||
- **Duplication by design:** The AuthGuard client exists in four languages on purpose. Q-008 covers where the behaviour has drifted.
|
||||
- **Not run:** No lint, build, test, `go vet`, `ruff`, `svelte-check` or `npm` command was executed. All findings are from reading the code.
|
||||
- **Verification:** Node backend: 73 tests passed. Python backend: 122 tests and Ruff passed. Web-ui: 29 tests, package build, `svelte-check`, `npm run lint`, and `format:check` passed. Go: `gofmt -l`, `go test ./...` and `go vet ./...` passed. Java tests were not run because no JDK or Maven is available. No database-backed integration test ran.
|
||||
- **Not verified:** Whether consumers depend on the removed `UserManagement` export or the `MediaPlayerControls` barrel removal (the changeset says only AuthGuard used it). Whether the `packages/media-shared-assets` and `media-backend` paths in history were ever shipped.
|
||||
- **Excluded from analysis:** `packages/web-ui/dist` and `.svelte-kit` (gitignored, not tracked), `package-lock.json` and `go.sum` (versions only), test bodies beyond coverage notes.
|
||||
Reference in new issue
Block a user