BizBox.WebApi.Template
1.2.0
See the version list below for details.
dotnet new install BizBox.WebApi.Template::1.2.0
π BizBox WebAPI Template
Version 1.2.0 - Enterprise-grade .NET 8 Web API template with HIPAA-ready security features
π Table of Contents
- Overview
- Installation
- Quick Start
- Features
- Documentation
- Architecture
- Security
- Project Structure
- Development
- Deployment
- Version History
- Support & Contributing
π― Overview
BizBox is a production-ready .NET 8 Web API template built with Clean Architecture principles, featuring enterprise-grade security, HIPAA-compliant audit logging, and comprehensive authentication/authorization systems. Perfect for healthcare, finance, and high-security applications.
π Key Highlights
- π Enterprise Security - Multi-layer defense with JWT, encrypted payloads, token blacklist
- π₯ HIPAA-Ready Features - Comprehensive audit logging, encryption at transit, secure logout
- π‘οΈ Advanced Protection - BOLA/IDOR prevention with ticket-based authorization
- π¬ Real-time Messaging - SignalR-powered WebSocket communication
- ποΈ Clean Architecture - Maintainable, testable, scalable codebase
- π Audit Trail - Automatic change tracking with old/new values, duration monitoring
- π Session Management - Configurable single/multi-device policies with proper logout
- π§ Invitation System - Email-based user onboarding
- π Template Ready - Install from NuGet, customize, and deploy
π Current Status
| Metric | Status | Notes |
|---|---|---|
| Overall Security | 82% Complete | β 16/19 items implemented |
| HIPAA Compliance | 50% Complete | π§ Core features done, encryption pending |
| Production Ready | β Yes | Secure for non-PHI workloads |
| HIPAA PHI Ready | π§ In Progress | Encryption at rest pending |
π¦ Installation (from NuGet)
Install the Template
dotnet new install BizBox.WebApi.Template
Create a New Project
# Create from template
dotnet new bizboxapi -n MyCompanyName.ProjectName
# Navigate to project
cd MyCompanyName.ProjectName
# Open in IDE
code . # VS Code
# or
start MyCompanyName.ProjectName.sln # Visual Studio
Verify Installation
dotnet new bizboxapi --help
π Quick Start
1. Generate Secrets
# Windows
Generate-Secrets.bat
# Or PowerShell
.\Generate-Secrets.ps1
This will generate all required secrets and optionally save them to a .env file.
1. Database Setup
# Create PostgreSQL databases
createdb BizBox.Db # Main database
createdb BizBox.AuditDb # Audit database (HIPAA requirement)
2. Configure Secrets
cd MyProject.API
# Initialize User Secrets
dotnet user-secrets init
# Set required secrets
dotnet user-secrets set "ConnectionStrings:Default" "Host=localhost;Port=5432;Username=postgres;Password=yourpassword;Database=BizBox.Db"
dotnet user-secrets set "ConnectionStrings:AuditDb" "Host=localhost;Port=5432;Username=postgres;Password=yourpassword;Database=BizBox.AuditDb"
dotnet user-secrets set "Jwt:Key" "your-super-secret-jwt-key-min-32-characters-long"
dotnet user-secrets set "Encryption:Key" "12345678901234567890123456789012"
dotnet user-secrets set "Encryption:IV" "1234567890123456"
dotnet user-secrets set "SuperAdmin:Email" "admin@yourdomain.com"
dotnet user-secrets set "SuperAdmin:Password" "SecurePassword123!"
2. Apply Migrations
# Main database
dotnet ef database update --context ApplicationDbContext
# Audit database
dotnet ef database update --context AuditDbContext
3. Run the Application
dotnet run --project BizBox.API
API: https://localhost:7264
Swagger: https://localhost:7264/swagger
SignalR Test: https://localhost:7264/signalr-test-client.html
π Need help? See docu/QUICK_START.md for detailed setup
β¨ Features
π Security Features (82% Complete)
β Implemented (16/19)
Authentication & Authorization:
- β JWT Authentication with HS256/RS256 support
- β Role-based authorization (Admin, SuperAdmin, Finance)
- β Token versioning (concurrent session detection)
- β Encrypted JWT payloads (AES-256)
- β Ticket-based authorization (BOLA/IDOR protection)
- β Password hashing (PBKDF2 with salt)
- β Email confirmation
- β Invitation-based registration
- β
Token Blacklist (NEW in v1.2.0 β¨)
- Immediate token invalidation on logout
- "Logout all devices" functionality
- Database-backed with automatic cleanup
- Background cleanup service (hourly)
- Works across load-balanced servers
- Proper logout that actually works!
- β
Account Lockout (v1.1)
- Automatic lockout after 5 failed attempts
- 15-minute lockout duration (configurable)
- Admin unlock capability
- Full audit trail integration
Audit & Monitoring:
- β
Comprehensive Audit Logging
- Automatic change tracking for all entities
- Old/new value capture
- User and operation tracking
- Duration and IP address logging
- Separate audit database (HIPAA requirement)
- β Structured logging with Serilog
- β Security event tracking
API Protection:
- β
Rate limiting (AspNetCoreRateLimit)
- Login: 5 attempts per 15 minutes
- Registration: 3 per hour
- General API: 100 per minute
- β IP-based rate limiting
- β Configurable per-endpoint limits
- β IP whitelist support
Configuration Security:
- β User Secrets (Development)
- β Environment Variables (Production)
- β Azure Key Vault ready
- β Secrets generator tool
- β
Configurable Identity Settings
- Lockout policy via appsettings.json
- Password requirements configurable
- Environment-specific overrides
Transport Security:
- β HTTPS enforcement
- β HSTS headers
- β CORS configuration
- β Secure WebSocket (SignalR)
Session Management:
- β Single/Multiple/Limited session modes
- β Multi-device tracking
- β Logout current device (with blacklist)
- β Logout all devices (with blacklist)
- β Session info endpoint
π§ In Progress (18%)
Priority 2 (P2):
- Two-Factor Authentication (2FA) - TOTP-based additional security layer
- Input Sanitization - Enhanced XSS protection with HtmlSanitizer
- Security Headers - CSP, X-Frame-Options, X-Content-Type-Options, HSTS
Priority 3 (P3):
- Encryption at Rest - Database field encryption (HIPAA critical)
- CSRF Protection - Anti-forgery tokens for state-changing operations
π Detailed Status: See docu/SECURITY_AUDIT.md
π¬ Real-time Features (SignalR)
- β Private messaging
- β Group chat
- β Online/offline status
- β Multi-device support
- β Typing indicators
- β System notifications
- β Auto-reconnection
- β JWT authentication
π― Application Features
- β User management (Identity framework)
- β Email invitation system
- β Global exception handling
- β Input validation (FluentValidation)
- β AutoMapper object mapping
- β MediatR CQRS pattern
- β Swagger/OpenAPI documentation
- β API versioning
- β Sample CRUD operations
π Documentation
π Getting Started
- Quick Start Guide - Get up and running in 5 minutes
- Secrets Setup - Configure development secrets
π Security
- Security Audit - Comprehensive security assessment
- Account Lockout Documentation - Account lockout feature guide
- Account Lockout Testing - Test procedures
- Identity Configuration Guide - Configure lockout & password policies
ποΈ Database & Audit
- Audit Database Setup - Configure separate audit database
- Audit Logging Guide - Use audit system
π Learning
- Clean Architecture Guide - Deep dive into architecture patterns
- Security-First Development - Building secure code from the start
π³ Deployment
- Docker Secrets Guide - Secure Docker deployment
ποΈ Architecture
BizBox follows Clean Architecture (Onion Architecture) with clear separation of concerns:
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BizBox.API (Presentation) β
β ββ Controllers (API Endpoints) β
β ββ Middleware (Authentication, rate limiting) β
β ββ Hubs (SignalR) β
β ββ Configurations (DI, services setup) β
βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β BizBox.APPLICATION (Use Cases) β
β ββ Commands (Write operations - CQRS) β
β ββ Queries (Read operations - CQRS) β
β ββ Validators (FluentValidation) β
βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β BizBox.DOMAIN (Entities) β
β ββ Entities (Core business objects) β
β ββ Value Objects β
β ββ Domain Interfaces (Contracts) β
βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β BizBox.PERSISTENCE (Data Access) β
β ββ DbContext (EF Core contexts) β
β β ββ ApplicationDbContext (Main data) β
β β ββ AuditDbContext (Audit logs) β
β ββ Migrations (Database versions) β
β ββ Configurations (Entity configurations) β
βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β BizBox.SERVICES (Infrastructure) β
β ββ TokenBlacklistService (Token invalidation) β
β ββ EmailService (SMTP integration) β
β ββ EncryptionService (AES-256 crypto) β
β ββ CurrentUserService (User context) β
β ββ AuditCaptureService (Audit logging) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Security
Defense-in-Depth Architecture
Layer 1: Rate Limiting (DDoS protection)
β
Layer 2: HTTPS/TLS (Transport encryption)
β
Layer 3: JWT Authentication (Identity)
β
Layer 4: Token Blacklist (Logout validation) β NEW!
β
Layer 5: Token Versioning (Session security)
β
Layer 6: Role Authorization (Access control)
β
Layer 7: Ticket Validation (BOLA protection)
β
Layer 8: Input Validation (Data integrity)
β
Layer 9: Audit Logging (Monitoring & compliance)
HIPAA Compliance Status
| Requirement | Status | Implementation |
|---|---|---|
| Access Control | β Complete | Role-based, ticket validation, account lockout, token blacklist |
| Audit Controls | β Complete | Comprehensive audit logging (separate database) |
| Person/Entity Authentication | β Complete | JWT + email verification + lockout + proper logout |
| Transmission Security | β Complete | HTTPS/TLS, encrypted JWT payloads (AES-256) |
| Integrity Controls | π§ Partial | Change tracking implemented, hash verification pending |
| Encryption at Rest | β Pending | Database field encryption (P3 - Critical for PHI) |
Current Score: 50% HIPAA Compliant (16/32 requirements)
π Project Structure
BizBox.WebApi.Template/
β
βββ BizBox.API/ # π Presentation Layer
β βββ Controllers/
β β βββ AuthController.cs # Authentication (+ new logout endpoints)
β β βββ UserController.cs
β β βββ AuditLogController.cs
β βββ Middleware/
β βββ TokenBlacklistMiddleware.cs # Token blacklist validation (NEW)
β βββ TokenVersionValidationMiddleware.cs
β βββ TicketValidationMiddleware.cs
β
βββ BizBox.APPLICATION/ # πΌ Application Layer
β βββ Auth/
β βββ Commands/
β βββ Logout.cs # Logout command (NEW)
β βββ LogoutAllDevices.cs # Logout all devices (NEW)
β
βββ BizBox.DOMAIN/ # π― Domain Layer
β βββ Entities/
β β βββ TokenBlacklist/
β β β βββ TokenBlacklist.cs # Token blacklist entity (NEW)
β β βββ User/
β β βββ ApplicationUser.cs
β βββ Interfaces/
β βββ ITokenBlacklistService.cs # Token blacklist contract (NEW)
β
βββ BizBox.PERSISTENCE/ # ποΈ Persistence Layer
β βββ Context/
β β βββ ApplicationDbContext.cs # Main database (+ TokenBlacklist)
β β βββ AuditDbContext.cs
β βββ Migrations/
β β βββ *_TokenBlacklist.cs # Token blacklist migration (NEW)
β β βββ Audit/
β βββ Configurations/
β βββ TokenBlacklistConfiguration.cs # EF config (NEW)
β
βββ BizBox.SERVICES/ # βοΈ Infrastructure Layer
βββ TokenBlacklistService/ # (NEW)
βββ DatabaseTokenBlacklistService.cs
βββ TokenBlacklistCleanupService.cs
π οΈ Development
Running Locally
# Development mode with watch
dotnet watch --project BizBox.API
# Run without watch
dotnet run --project BizBox.API
Database Migrations
# Main Database
dotnet ef migrations add MigrationName \
--project BizBox.PERSISTENCE \
--startup-project BizBox.API \
--context ApplicationDbContext
# Audit Database
dotnet ef migrations add MigrationName \
--project BizBox.PERSISTENCE \
--startup-project BizBox.API \
--context AuditDbContext \
--output-dir Migrations/Audit
# Apply Migrations
dotnet ef database update --context ApplicationDbContext
dotnet ef database update --context AuditDbContext
π Version History
π Version 1.2.0 (Current - January 2025)
π Major Feature: Token Blacklist
- β
Proper Logout Functionality
- Immediate token invalidation on logout
- "Logout all devices" with bulk token blacklisting
- Database-backed blacklist (PostgreSQL)
- Token blacklist middleware (validates on every request)
- Background cleanup service (removes expired tokens hourly)
- Configurable cleanup interval and batch size
- Works across load-balanced servers
- No more "JWT tokens can't be revoked" problem!
New Endpoints:
POST /api/auth/logout-v2- Logout from current devicePOST /api/auth/logout-all-devices- Logout from all devices
Database Changes:
- New
TokenBlacklisttable with performance indexes - Automatic migration included
- Configurable via
appsettings.json
Security & Compliance:
- β Security Score: 78% β 82% (+4%)
- β HIPAA Compliance: 45% β 50% (+5%)
- β Items Complete: 15/19 β 16/19 security items
Documentation Added:
- Complete Token Blacklist architecture documentation
- Implementation guides and testing procedures
- Updated README with new features
π¦ Version 1.1.0 (December 2024 - January 2025)
Major Features:
- β Comprehensive Audit Logging System
- β Account Lockout System (TESTED β)
- β Configurable Identity Settings
- β 12-Factor App Methodology (12/12 complete)
Security:
- Security Score: 60% β 78% (+18%)
- HIPAA Compliance: 30% β 45% (+15%)
- Items Complete: 13/19 β 15/19
π¦ Version 1.0.0 (December 2024)
Initial Release:
- JWT authentication & authorization
- Rate limiting
- SignalR real-time messaging
- Session management
- Clean architecture foundation
- Published to NuGet
πΊοΈ Roadmap
β Version 1.2.0 (Current - January 2025)
- β Token Blacklist implementation
- β Proper logout functionality
- β "Logout all devices" support
- β Background cleanup service
- β 82% security completion
- β 50% HIPAA compliance
π Version 1.3.0 (Q1 2025) - Next Up
Priority 2 (P2) - High Security:
- Two-Factor Authentication (2FA) (1-2 weeks)
- TOTP-based implementation
- QR code generation
- Backup codes
- Input Sanitization (1 week)
- HtmlSanitizer integration
- XSS protection
- Content Security Policy headers
- Security Headers (2-3 days)
- CSP, X-Frame-Options, X-Content-Type-Options
- HSTS configuration
Expected Metrics:
- Security Score: 82% β 90%
- HIPAA Compliance: 50% β 70%
- Items Complete: 16/19 β 18/19
π Version 2.0 (Q2-Q3 2025)
- Encryption at rest (field-level)
- Full HIPAA compliance (95%+)
- OAuth/OIDC integration
- Advanced monitoring dashboard
- SOC 2 compliance ready
π€ Support & Contributing
Getting Help
- π Documentation: docu/ folder
- π Bug Reports: GitHub Issues
- π¬ Discussions: GitHub Discussions
Contributing
We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Follow our coding standards
- Write/update tests
- Update documentation
- Submit a pull request
π License
This project is licensed under the MIT License.
<div align="center">
Made with β€οΈ and π by the BizBox Team
β Star us on GitHub if this template helps your project!
π‘οΈ Security First. HIPAA Ready. Production Proven.
v1.2.0 - Now with Proper Logout! π
</div>
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version 1.2.0 - Token Blacklist Release (82% Security Complete)
🎉 MAJOR NEW FEATURE:
β’ Token Blacklist - Proper logout functionality that actually works!
- Immediate token invalidation on logout
- "Logout all devices" functionality
- Database-backed with automatic cleanup
- Background cleanup service (hourly)
- Works across load-balanced servers
- No more "JWT tokens can't be revoked" problem
β
COMPLETED SECURITY FEATURES (16/19):
β’ JWT Authentication with HS256/RS256 and encrypted payloads (AES-256)
β’ Token Blacklist with automatic cleanup (NEW - v1.2.0)
β’ Account Lockout (5 failed attempts, 15-min lockout) (v1.1.0)
β’ Comprehensive Audit Logging with separate database (v1.1.0)
β’ Token versioning for session management
β’ Encrypted ticket system (BOLA/IDOR protection)
β’ Rate limiting with AspNetCoreRateLimit
β’ Secrets management (User Secrets, Environment Variables, Key Vault ready)
β’ Session management (Single/Multiple/Limited modes)
β’ Role-based authorization (Admin, SuperAdmin, Finance)
β’ HTTPS enforcement with HSTS
β’ CORS configuration
β’ Password security with PBKDF2
β’ SignalR with JWT authentication
β’ Configurable identity settings
📈 METRICS:
β’ Security Score: 82% Complete (16/19 items)
β’ HIPAA Compliance: 50% Complete
β’ Production Ready: β
Yes
🏗οΈ ARCHITECTURE:
β’ Clean Architecture (5 layers)
β’ CQRS pattern with MediatR
β’ Repository pattern with EF Core
β’ PostgreSQL database (main + audit)
β’ Background services
📚 FEATURES:
β’ User management with ASP.NET Identity
β’ Email invitation system
β’ Multi-device session tracking
β’ Proper logout (current device & all devices)
β’ Real-time messaging (SignalR)
β’ Comprehensive documentation
β’ Swagger/OpenAPI
β’ Migration files included
β’ Secrets generator script
🚧 COMING IN v1.3 (Target: 90% Security):
β’ Two-Factor Authentication (2FA)
β’ Input Sanitization (XSS protection)
β’ Security Headers (CSP, X-Frame-Options)
β’ CSRF Protection
📦 WHAT'S INCLUDED:
β’ Complete source code with migrations
β’ Token blacklist implementation
β’ Audit logging system
β’ Account lockout system
β’ Generate-Secrets scripts (.bat & .ps1)
β’ Comprehensive documentation (12 guides)
β’ Test controllers for debugging
β’ Sample implementations