feat(BIT-183): admin auth, RBAC, audit logging, rate limiting
Implements BIT-154.7 — Auth administrativa, RBAC e quotas: - api/src/types/auth.ts: 3 roles (superadmin/admin/viewer), 18 permissions, ROLE_PERMISSIONS map as single source of truth - api/src/plugins/auth.ts: JWT via HTTP-only __Host- cookies (15min access / 7d refresh), token rotation, timing-safe login - api/src/plugins/rbac.ts: requirePermission() + requireRole() Fastify decorators for route-level enforcement - api/src/plugins/audit.ts: auditLog() helper + Fastify plugin; writes to audit_logs table; failure never aborts main operation - api/src/plugins/rate-limit.ts: per-route limits (login: 10/5min IP, ingest: 1000/min token, global: 500/min) + payload size enforcement - api/src/routes/admin/auth.ts: POST login, POST refresh, POST logout, GET /me — with audit events on all operations - db/migrations/001–004: admin_users, refresh_tokens, audit_logs tables + dev seed (bcrypt superadmin) - web/src/app/(admin)/login: Velzon Bootstrap 5 login page (Next.js client component, credentials:include, HTTP-only cookie flow) - docs/permission-matrix.md: full permission matrix + audit event catalogue + rate/payload limit table (BIT-183 acceptance criterion) Co-Authored-By: Paperclip <[email protected]>
This commit is contained in:
1 parent
d455a26333
commit
eeb5039a3c
21 files changed
+1455
No files matched your search
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@errors-bitreport/api",
|
||||
"version": "0.1.0",
|
||||
"description": "BitReport Error Reporting Platform — Fastify API",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"db:migrate": "node-pg-migrate -d $DATABASE_URL up",
|
||||
"db:migrate:down": "node-pg-migrate -d $DATABASE_URL down"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fastify/cookie": "^9.3.1",
|
||||
"@fastify/helmet": "^11.1.1",
|
||||
"@fastify/jwt": "^8.0.1",
|
||||
"@fastify/rate-limit": "^9.1.0",
|
||||
"@fastify/swagger": "^8.14.0",
|
||||
"@fastify/swagger-ui": "^3.0.0",
|
||||
"fastify": "^4.27.0",
|
||||
"pg": "^8.11.5",
|
||||
"pino": "^9.1.0",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.14.0",
|
||||
"@types/pg": "^8.11.6",
|
||||
"tsx": "^4.15.6",
|
||||
"typescript": "^5.4.5",
|
||||
"vitest": "^1.6.0"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user