Admin panel with a real login
Admin shell + real auth gate
For when the answer to “An admin back office to manage it” is yes.
Sidebar, tabs, CRUD tables, toast, with server-side auth and render-time escaping baked in, so the two things every hand-rolled admin gets wrong are impossible by construction.
Built by hand again in 14 of 20 audited projects before this existed. Each rebuild was another chance to make the mistake below.
Skip the rebuild
You do not write this one. It arrives in your project as ordinary source you can read, change and keep, with its audit record and its caveats beside it.
- Download the Playground. It is free and runs on your own machine.
- Start a new app and tick “An admin back office to manage it”.
- This block is written in, along with anything else you ticked.
The mistake it removes
Rebuilt in ~14/20 projects and flagged every time. Vibe Coder: '/admin is guarded only by robots noindex… the URL is guessable' and 'descriptions are trusted HTML at render time'. Coaching App: 'access tiers are cosmetic, not enforced'.
What the audit found
Named rather than summarized. The reasoning behind each one ships inside the block, so it travels with the code instead of living on a page you have to trust. A finding marked fixed was fixed after the audit ran; the verdict above is still the one the audit gave.
- ADMIN_SECRET is validated by length only: no format round-trip, no entropy floor major · Security Fixed after the audit in
7f81cce1c - Customer-facing claim that login IPs are 'held in memory only for a few minutes' is false; the attempts Map is never pruned and grows without bound major · Privacy & data Fixed after the audit in
745e681be - A malformed JSON string body answers 500 'login failed' instead of 400 minor · Error handling & resilience Fixed after the audit in
150ece9bc - One mutant survived: scrypt's error path resolving TRUE is not pinned by any test minor · Verification integrity Fixed after the audit in
840af0fe7 - Section switch race in the shell: a slower load can render under the wrong tab minor · Correctness Fixed after the audit in
3686abb00 - sessionStorage is accessed without a guard, so a blocked-storage browser throws out of createAdmin and nothing renders minor · Error handling & resilience Fixed after the audit in
366acbed8 - No server-side revocation: a token stays valid for 8 hours after a password change, and the block does not say so minor · Security Fixed after the audit in
736992cef
One more finding is written in the auditors' internal shorthand, so it is not listed here. The full text is in the report inside the block. It was fixed after the audit, in 6de3b1280.
What you still have to do
A copied file cannot own your secrets, your host or your legal obligations. This is the part the block deliberately does not claim.
- Serve /admin over HTTPS only and put ADMIN_SECRET and ADMIN_PASSWORD_HASH in your host's secret store (Vercel/Netlify/Fly environment, or a secrets manager). The block enforces the auth check and escapes at render time; it cannot supply the transport or the credential, and a guessable secret defeats both.
- A keyboard-and-screen-reader pass on YOUR page. The block ships the wiring it can ship (aria-live on the status region, aria-label on the controls, aria-current on the active section and autocomplete on the password field), but color contrast, heading order and the focus order across everything around it are properties of the page you drop this into, and no test here can see them. Run one manual keyboard pass and one screen-reader pass before you launch.
- A rate limiter backed by a shared store (Redis/Upstash) or by your edge (Cloudflare, Vercel firewall). The brute-force limiter shipped here is in-memory, so on serverless it only slows an attacker who keeps hitting the same warm instance.
- Requires a server. There is no client-only mode on purpose: that is the failure this block exists to end.
- Sessions are not stored on the server, so there is no per-session logout. Changing ADMIN_PASSWORD_HASH ends every session at once. Rotating ADMIN_SECRET also ends every session, without changing the password.
What lands in your project
node
- node/admin-auth.js
The gate. scrypt password hashing, HMAC-signed expiring tokens, timing-safe compares. Zero dependencies (node:crypto). Wrap every mutating handler in requireAdmin(req,res).
vanilla
- vanilla/admin-shell.js
The UI. Never decides auth (the server does) and never assigns data to innerHTML: every cell is textContent, so escaping is structural, not dependent on the write path.
What you supply
- ADMIN_SECRET: <64 to 1024 random hex chars, from randomBytes only, never an encoded phrase: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))">
- ADMIN_PASSWORD_HASH: <output of hashPassword('your-password'), never the password itself. SINGLE-QUOTE IT: the value contains `$`, which a shell, a sourced .env and docker-compose all expand, collapsing it to just `scrypt` (measured). A hash that does not arrive whole is REFUSED loudly: it is never treated as a wrong password>
Licensed MIT. It is a starting point, not a finished product.
Get it
Download the Playground See the other blocks
Nothing here is locked. The files are yours, in your folder, under a permissive license.
Questions
- Is Admin panel with a real login audited?
- It was audited on 2026-09-29, and the verdict was not a clean pass. 8 findings have been fixed since then, and the verdict stands until the block is audited again.
- What do I still have to do myself?
- Serve /admin over HTTPS only and put ADMIN_SECRET and ADMIN_PASSWORD_HASH in your host's secret store (Vercel/Netlify/Fly environment, or a secrets manager). The block enforces the auth check and escapes at render time; it cannot supply the transport or the credential, and a guessable secret defeats both.
- How do I get this code?
- Download the Playground, start a new app, and tick “An admin back office to manage it”. The block is written into your project as ordinary source you can read and edit.
All pre-built code blocks · Learn to build from zero · The coding guide