- Home
- Skills
- APIs & Backend
- Multi-Tenant Clinical Authorization Pattern (Node Kit)
Multi-Tenant Clinical Authorization Pattern (Node Kit)
This kit closes each of those as a working reference implementation on node:sqlite that you can read, run and port.
$39
Works with the AI Agents you already use
Multi-Tenant Clinical Authorization Pattern (Node Kit)
Example session with this skill installed
Review the authorization in my practice-management API against this pattern: every client route, the vendor support path, note editing, and report approval. Tell me where we are exposed.
- Read your context and instructions
- Compiled the multi-tenant clinical authorization
Summary
Four gaps against the pattern; two are serious.
Findings
Guessed ids open records. GET /clients/:id looks the client up directly; the directory is filtered but the record route is not. Route it through a single-record gate that returns 404 when the caller may not see the client (visibleClientOrNull).
2.
Vendor admins read live tenants. Platform admins bypass membership with no grant. Add data_mode, return 403 SUPPORT_ACCESS_REQUIRED on live tenants without an unexpired owner-issued grant, audit first use once.
3.
Signed notes are editable. PATCH /notes/:id has no status check. Make sign terminal and add an amendment route that references the original.
4.
Approval without reading. POST /reports/:id/approve checks role only. Require a different user and an audited report.opened_for_review event by that user.
Also
The audit table has no chain or sequence; a DBA can rewrite it silently. Add the per-tenant HMAC chain and an external anchor, and expose a read-only integrity endpoint to the owner and auditor roles.
Connects securely to your tools. The creator never sees your data.
About this skill
A multi-tenant application that holds protected records fails in predictable places: a filtered directory next to a record route that accepts any id, a vendor administrator who can read live records "for support", a signed note that can still be edited, an approval given without reading, and an audit table the same database user can rewrite. This kit closes each of those as a working reference implementation on node:sqlite that you can read, run and port.
Three independent server-side checks (clinic.mjs): tenant membership (403 for a tenant you are not in, 404 for its records), per-tenant role sets, and per-record visibility at four levels (practice, assigned, supervisors, owner-only) decided by one function and consumed by a single-record gate that returns 404 and a SQL fragment that matches nothing when the visible set is empty.
Vendor boundary: tenants are synthetic or live; a platform admin on a live tenant gets 403 SUPPORT_ACCESS_REQUIRED until the tenant owner issues a 15-240 minute grant with an encrypted reason; first use audited once, revocable by the owner only, never self-issued, re-checked on every request.
Records: draft notes are author-only, signing is terminal, later changes are amendments that reference the original. Outbound reports need a second person who has an audited opened_for_review event of their own before approve succeeds.
field-crypto.mjs: AES-256-GCM with HKDF-derived keys, the column and record bound as additional authenticated data, HMAC blind indexes for equality lookups.
audit-chain.mjs: per-tenant HMAC chain with sequence numbers; verification names chain_discontinuity, event_hash_mismatch, sequence_gap and, against an external anchor, tail_truncation including delete-then-reissue laundering; legacy rows counted not passed.
Reference: the model, a role matrix, the audit-chain notes. 11 tests and a narrated demo. Node 22.5+, no packages, no network.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Reference implementation for porting, not a standalone library. Requires Node 22.5+. Does not cover authentication, key rotation, or specific regulatory compliance certifications.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 18 days ago
- Software
node
Permissions
Runs node against an in-memory SQLite database for the tests and demo; no network, no environment variables, no files written outside the project unless you point it at a database path.