Role structure:
- Admin (3): Full access to all pages and operations
- Manager (2): Access all pages + admin panel, but can only add users (not delete)
- Staff (1): Access consultants/analytics/browse (read-only), can save corrections
Changes:
- Rename employee→manager, viewer→staff in role definitions
- Update PAGE_ACCESS to reflect new permissions
- Add admin-only authorization checks on all delete endpoints
- /admin/corrections/delete
- /browse/delete, /browse/edit
- /analytics/delete
- Update admin.html with new role select options (staff/manager/admin)
- Hide delete buttons from non-admin users in corrections table
- Allow managers to access admin navigation link in base.html and home.html
- Add .role-manager CSS styling (blue/purple)
- Update database default role from employee to staff
- Remove obsolete .role-employee CSS selector
Backward compatibility: Existing 'employee' and 'viewer' users need migration:
UPDATE users SET role = 'manager' WHERE role = 'employee';
…
Apply security hardening across FastAPI and Webapp
- Remove hardcoded admin email fallback; require ADMIN_EMAIL env var
- Reduce session lifetime from 3650 days to 30 days
- Set secure=True on session cookies (opt-out via ENVIRONMENT=local)
- Add HTTP security headers middleware (X-Frame-Options, X-Content-Type-Options, HSTS, etc.)
- Require authentication on /api/services and /api/type-cluster-map
- Sanitize 500 error messages to avoid leaking exception details
- Validate role enum on user add/update (whitelist: admin/employee/viewer)
- Add 5000-char limit on prediction quotes; raise password minimum to 8 chars
- Call cleanup_expired_sessions() on startup to prune stale tokens
- Guard admin seed row against empty ADMIN_EMAIL in both databases
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>