auth-session-and-safety-boundaries

Enforces auth middleware, typed sessions, and fail-closed handling for Express API routes.

Updated Dec 24, 2025
One-click install
npx skills add https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1 --skill auth-session-and-safety-boundaries-joyjoin-tech-limited
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: auth-session-and-safety-boundaries
Source: https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1/tree/main/.github/skills/auth-session-and-safety-boundaries
Command: npx skills add https://github.com/JoyJoin-Tech-Limited/JoyJoin_app_v0.1 --skill auth-session-and-safety-boundaries-joyjoin-tech-limited

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? It prevents inconsistent or missing authentication on Express API routes by enforcing shared auth middleware, typed session access, gated dev-only auth tooling, and fail-closed behavior for sensitive flows like webhooks. ## Core Features & Use Cases - Admin Route Gating: Ensures every /api/admin/* route uses requireAdmin, requireSuperAdmin, or requireOperatorOrAbove middleware aligned with the RBAC matrix. - Dev Auth Tool Isolation: Gates debug and mock WeChat auth endpoints behind ENABLE_DEV_AUTH_TOOLS=1 so they never ship to production. - Webhook Signature Verification: Verifies WeChat Pay webhook signatures against the raw request body before processing payload data, returning 400 on failure. - Use Case: When adding a new /api/admin/reports endpoint, apply requireOperatorOrAbove middleware and log the action via the admin audit logger instead of writing an ad-hoc session check. ## Quick Start Ask the assistant to add an admin-only API route with proper auth middleware and audit logging following the auth safety guidelines.

Frequently Asked Questions about auth-session-and-safety-boundaries

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add an admin-only API route in Express?▼

Add the requireAdmin middleware from adminAuth.ts before the route handler, or use requireOperatorOrAbove for finer-grained RBAC. Log the action via the admin audit logger and cross-reference the admin RBAC matrix instead of writing inline session checks.

How do I create a dev-only auth endpoint that never reaches production?▼

Gate the route behind a check that process.env.ENABLE_DEV_AUTH_TOOLS equals '1', returning 404 otherwise. On the client, require both import.meta.env.DEV and VITE_ENABLE_DEV_TOOLS=1 so the tooling is absent in production builds.

Why is my WeChat Pay webhook signature verification failing?▼

Signature verification fails when the parsed JSON body is used instead of the raw request body for signature calculation. Also confirm the WeChat Pay secret or platform certificate is correctly loaded from environment variables, and return 400 with logging on failure.

Why do I get unexpected 401 or 403 errors in production?▼

Check that session cookie settings (domain, path, httpOnly, secure, sameSite) match the frontend origin and HTTPS configuration. Also verify auth middleware ordering in routes.ts and that RBAC role resolution returns the expected role.

What session cookie settings are required for production?▼

Production session cookies must use httpOnly: true, secure: true, and sameSite set to 'lax' or 'strict'. Never relax secure: true for any production codepath, and avoid storing sensitive state in client-accessible cookies.