Repository navigation
Release prep v0.9.0: Nasaq 1.x, CI, admin API contract, flow tests (#2) - #3
Merged
Merged
Conversation
Port to @fadymondy/nasaq ^1.2.0 and Next 16 conventions, align the client with the auth admin API (togo-framework/auth#5/#6) including the impersonation security model and /reset-password, add a web CI job with a harness, committed Vitest flow tests and Go tests for the mail admin guard, bump togo to v0.21.0. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tor) with tests Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…n pages; vitest coverage
…), demoted/deleted admins on mail routes, pinned-version check, Postgres variant Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…test commands Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e CI toolchain) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Author
dashboard#3 release gate: FAIL (F2, Medium). Release gate stopped.Reviewed commit: F2 (Medium): the stored SMTP password can be recovered
Low findings (documented with reproductions; recommended for the same contained fix or a follow-up)
What passed
FAIL. The release gate is stopped. No merge, tag or deployment was performed. 🤖 Generated with Claude Code |
…laceholder)
kvSet bound placeholder 2 twice, which on drivers with positional ? placeholders
means three binds for two arguments ("missing argument with index 3"). Use
excluded.v, valid on SQLite and PostgreSQL. Successful PUTs are now asserted as
exactly 200.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tion PUT /mail kept the stored password for a blank or masked value even when the host changed, so POST /mail/test then sent it to the new host. Retain it only when host, port, username and TLS mode are unchanged; otherwise answer 400 before anything is written. A config without a username sends no credentials, so the old password is dropped instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
auth's RequireRole only checks the role, so with AUTH_ADMIN_CROSS_CONTROL=true a borrowed admin session reached the SMTP routes. Add a guard after it that mirrors auth's requireAdmin: impersonated and PAT callers get 403. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…il routes Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
Author
dashboard#3 contained fixes (F2, F4, F1): PASS on
|
| Commit | Fix |
|---|---|
352f495 |
F2: the stored SMTP password is kept only while host, port, username and security mode are unchanged. Host comparison ignores case and surrounding whitespace, and port 0 is treated as 587. If any of these change and the request sends no password (or the mask), the server returns 400 with "password required when changing SMTP host, port, username or security" and writes nothing. Changing only From keeps the password. A new config with no username sends no credentials, so the old password is dropped and is not carried forward to a later change. F4: the root cause was the upsert DO UPDATE SET v=ph(2), which reused a placeholder: SQLite's positional ? then needed 3 arguments where 2 were bound. It now uses SET v=excluded.v, which works on both SQLite and Postgres. |
2fd4a79 |
F1: refuseBorrowedAdmin, placed after RequireRole("admin"), applies the same check as auth's own requireAdmin (Impersonator != "" or Guard == "pat" gets 403). Auth itself is unchanged. |
894d350 |
F5: the layout.tsx comment is corrected. It is a comment-only change. |
af25dc4 |
Adds a test that an admin's PAT is refused on every mail route. Auth already gives a PAT no account roles, so RequireRole refuses it first and the dashboard check is a second layer. |
Tests
- Go: 19 tests pass on SQLite and on Postgres (
-tags dashpg, throwaway DB). There are no skips.go vetandgo mod verifyare clean. - New regression tests:
- A PUT that changes host, port, username or security without a password returns 400, and the stored row is byte-identical afterwards.
- Keeping the same connection keeps the password, and a new password is stored.
- Mail test-send after a rejected PUT never sends the old password to the new host.
- The first insert and the upsert both return exactly 200 on every driver.
- An impersonated admin under
AUTH_ADMIN_CROSS_CONTROL=truegets 403, while normal admins get 200. - An admin PAT gets 403.
- Assertions: the demoted-admin pre-check went from "not 401/403" to exactly 200. No assertion was weakened.
- Web: lint, typecheck, build and 44/44 tests pass.
Independent scoped review (security-engineer, not the author): PASS, no Medium or higher
- F2: it held up against normalization tricks (case, whitespace, trailing dot, IP, port default, Secure toggle, mask, missing fields) and against two-step sequences.
- Mutation testing: neutering
sameConnectionor the impersonation check makes the tests fail. - Its one Low ("PAT branch untested") was based on a mistaken premise. Auth v0.10.0
revalidate(keepGrants=true)gives PATs no roles. The PAT refusal is now pinned end-to-end inaf25dc4, which changes tests only, and every Go gate and CI was rerun on it.
Dependency
togo v0.21.0 is required. auth v0.10.0's go.mod requires togo v0.21.0 (go mod graph), so minimal version selection forces it. It is kept.
Remaining findings (non-blocking, owner-deferred)
These are tracked in dashboard#4:
- F3: no SMTP timeout or rate limit.
- F6: raw error text is shown.
- F7: the admin client has no CSRF header or resource allowlist.
- Three Info notes.
PASS — dashboard#3 is ready for human merge/tag approval. No merge, tag or deployment performed.
🤖 Generated with Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
@fadymondy/nasaq ^1.2.0(no breakages: tsc andnext buildclean). Next 16 conventions: flat ESLint (nonext lint), react-hooks v7 clean, router-based navigation./api/auth/admin/*,/api/auth/csrf,/api/auth/me,/api/auth/impersonation/stop,/api/auth/password/reset): typed 401/403/404 errors, forbidden state (no crash), CSRF on writes only, admin calls always use the admin session.me.impersonator, explicit End callsPOST /api/auth/impersonation/stopwith the impersonation bearer, bearer sent only on acting-as-user calls (never/admin/*), Users/Mail nav and pages blocked while impersonating, expired token falls back to the admin session./reset-password?token=page posting{token, password}. Reset/magic-link 403 for admin targets (AUTH_IMPERSONATE_ADMINSunset) shows a toast, not a forbidden page.Submitbutton nowtype="submit"(Nasaq 1.x Button defaults totype="button", which silently broke every auth form).gojob (Go version from go.mod) plus newwebjob:test-harness/assemble.mjsinjectsweb/into a minimal Next project, thennpm ci, lint, typecheck, test, build.RequireRole: anonymous 401, non-admin 403 on GET/PUT/POST; admin passes. togo bumped to v0.21.0.Why
Release train circlexo/apps#78. CI root cause: the premise did not reproduce (runs on 97eaec3 are green, Actions enabled); the real gap was that CI covered Go only, so web breakage was never exercised. The web job closes that.
How tested
Locally in the harness: eslint (0 errors, 2 warnings:
window.location.hreffor dev-login/SSO external redirects),tsc --noEmit, Vitest 22/22,next build;go vetandgo testpass.Dependency on auth#5 / #6
Client assumes the contract of togo-framework/auth#6 (target v0.10.0, under security review, unmerged).
go.modstays on auth v0.8.0: bump to v0.10.0 once tagged (no replace, no pseudo-version). Until then admin user management returns 404 from older auth.Security audit
Impersonation
Profile and /two-factor show no password, PIN or 2FA controls while impersonating, with a note that they belong to the account holder (Vitest covered). The plugin has no API-token UI. Server 403 remains the boundary.
Gaps
Closes #2. Part of circlexo/apps#78.
🤖 Generated with Claude Code