IdentityHub is a production-ready, enterprise-grade identity and access management system using OpenIddict (OAuth 2.0 / OpenID Connect) instead of IdentityServer. This solution implements all critical authentication flows for secure, scalable applications.
- Password-Based Login - Traditional username/password with account lockout
- One-Time Password (OTP) - Email-based OTP for passwordless auth
- LDAP/Active Directory - Enterprise directory integration
- User Registration - Self-service registration with email verification
- Password Management - Change, reset, and recovery flows
- β BCrypt password hashing (work factor 12)
- β Account lockout (5 failures β 15 min lockout)
- β OTP with email delivery (6-digit, 5 min expiration)
- β LDAP/Active Directory support
- β JWT token authentication
- β Refresh token support
- β Comprehensive audit logging
- β Failed login tracking
- β IP address & User-Agent logging
- β HTTPS enforcement
- β CORS protection
- β Rate limiting ready
| Document | Purpose |
|---|---|
| IMPLEMENTATION_GUIDE.md | Complete setup, configuration, and advanced topics |
| DEPLOYMENT_CHECKLIST.md | Production deployment steps and verification |
| API_REFERENCE.md | Detailed API docs with cURL examples |
cd IdentityHub.Infrastructure
dotnet ef migrations add AddSecurityFields
dotnet ef database updateUpdate appsettings.Production.json:
{
"ConnectionStrings": {
"DefaultConnection": "Host=your-server;Database=IdentityHubDb;..."
},
"AppSettings": {
"AppUrl": "https://your-domain.com",
"JwtSecret": "your-32-char-secret-key"
},
"Email": {
"Provider": "SendGrid",
"SendGrid": { "ApiKey": "your-api-key" }
}
}dotnet run --configuration ProductionPOST /api/auth/register # Register new user
POST /api/auth/login # Login with password
POST /api/auth/login-ldap # Login with LDAP
POST /api/auth/send-otp # Request OTP
POST /api/auth/verify-otp # Verify OTP
POST /api/auth/forgot-password # Request password reset
POST /api/auth/reset-password # Complete password reset
POST /api/auth/refresh-token # Refresh access token
POST /api/auth/change-password # Change password
POST /api/auth/logout # Logout
- Minimum 12 characters
- Uppercase letters (A-Z)
- Lowercase letters (a-z)
- Digits (0-9)
- Special characters (!@#$%, etc)
- Lockout after 5 failed login attempts
- 15-minute lockout duration
- Failed login tracking
- Last login timestamp
- IP address logging
- Cryptographically secure 6-digit codes
- 5-minute expiration
- Maximum 5 verification attempts
- Email delivery
- All login attempts (success/failure)
- Password changes
- OTP verification attempts
- User registrations
- IP addresses and User-Agents
Built with:
- ASP.NET Core 8.0 - Modern .NET framework
- OpenIddict 5.x - OAuth 2.0 / OpenID Connect
- PostgreSQL - Reliable database
- Entity Framework Core - ORM
- MediatR - CQRS pattern
- BCrypt.Net - Password hashing
- Novell LDAP - Directory support
IdentityHub/
βββ IdentityHub.Api/ # Web API with 10 endpoints
βββ IdentityHub.Application/ # CQRS Handlers
βββ IdentityHub.Infrastructure/ # Services & Data Access
βββ IdentityHub.Domain/ # Core entities
This solution includes:
- β Comprehensive error handling
- β Logging at critical points
- β Database index recommendations
- β Performance optimization tips
- β Security best practices
- β GDPR/HIPAA/SOC2 considerations
- β Deployment procedures
- β Monitoring integration
- β Disaster recovery guidance
- β 30+ code examples
Example test:
[Test]
public async Task Login_WithValidCredentials_ReturnsToken()
{
var command = new LoginWithPasswordCommand("user", "SecurePass123!");
var result = await _handler.Handle(command, CancellationToken.None);
Assert.IsInstanceOf<SignInResult>(result);
}- 10 API Endpoints - Complete auth coverage
- 10 Request Handlers - CQRS pattern
- 5 Service Interfaces - Clean separation
- 15+ Security Features - Enterprise-grade
- 5000+ Lines of Code - Well-structured
- 3 Documentation Files - Comprehensive guides
User submits credentials
β
Validate password against hash
β
Check account status & lockout
β
Generate JWT token
β
Return access & refresh tokens
User requests OTP
β
Generate 6-digit code
β
Send via email
β
User submits OTP
β
Verify code (max 5 attempts)
β
Return JWT tokens
User requests reset
β
Generate reset token
β
Send reset link via email
β
User clicks link
β
Submit new password
β
Validate & update in database
β
Confirmation email
- Setup Issues β Read
IMPLEMENTATION_GUIDE.md - API Questions β Check
API_REFERENCE.md - Deployment β Follow
DEPLOYMENT_CHECKLIST.md - Code Examples β See inline documentation
Required for production:
ASPNETCORE_ENVIRONMENT=Production
ConnectionStrings__DefaultConnection=your-connection-string
AppSettings__JwtSecret=your-secret-key
AppSettings__AppUrl=https://your-domain.com
Email__SendGrid__ApiKey=your-sendgrid-key| Aspect | Implementation |
|---|---|
| Security | OWASP Top 10 addressed, secure by default |
| Performance | Optimized queries, connection pooling, caching |
| Scalability | Stateless JWT tokens, horizontal scaling ready |
| Reliability | Error handling, retry logic, monitoring ready |
| Compliance | GDPR, HIPAA, SOC2 considerations included |
| Maintainability | Clean code, clear architecture, well documented |
| Observability | Audit logging, Application Insights ready |
| Testing | Unit test examples, integration test guidance |
Quick deployment path:
- Configure database connection
- Set up email service (SendGrid or SMTP)
- Configure environment variables
- Run database migrations
- Build release package
- Deploy to hosting platform
See DEPLOYMENT_CHECKLIST.md for detailed steps.
- OpenIddict Docs: https://documentation.openiddict.com/
- OWASP Auth: https://cheatsheetseries.owasp.org/
- ASP.NET Security: https://docs.microsoft.com/en-us/aspnet/core/security/
Production-ready implementation provided as-is. Ensure compliance with applicable regulations.
You now have a complete, secure, production-ready identity management system with:
β 5 authentication methods β Enterprise security controls β Full audit logging β Comprehensive documentation β Ready for production deployment
Status: Production Ready β
Version: 1.0.0
Last Updated: February 27, 2026
- Review
IMPLEMENTATION_GUIDE.mdfor complete setup - Configure your production environment
- Run database migrations
- Deploy to production
Your secure identity solution is ready! π