A Go-based passwordless authentication system using OTP (One-Time Password) with enterprise-grade security features.
- Features
- Architecture
- Getting Started
- Configuration
- Security
- API Documentation
- Development
- Deployment
- License
- 🔐 OTP Generation and Verification
- 🔑 JWT-based Authentication
- 📱 Session Management
- 🔄 Refresh Token Support
- 🛡️ Rate Limiting
- 🚦 Security Headers
- 📝 Request Logging
- ⚙️ Configurable Security Settings
- 📊 Prometheus Metrics Collection
- 🔍 Distributed Tracing with OpenTelemetry
- ⚡ Circuit Breaker for External Services
- 🏥 Health Checks and Service Status
- ⚙️ Configuration Management with Viper
- 🛑 Graceful Shutdown
- 📈 Metrics Dashboard Integration
- 📝 Advanced Logging with Correlation IDs
- 🔄 Service Discovery Ready
- 🏥 Container Health Probes
├── cmd/
│ ├── server/ # Application entry point
│ └── encrypt/ # Configuration encryption utility
├── internal/
│ ├── api/
│ │ ├── handlers/ # Request handlers
│ │ └── routes/ # Router setup
│ ├── auth/ # Authentication logic
│ ├── config/ # Configuration
│ ├── middleware/ # Security middleware
│ ├── services/ # External services (SMS, etc.)
│ └── models/ # Data models
├── pkg/ # Public packages
└── README.md
- API Layer: HTTP handlers and route definitions
- Authentication: OTP and JWT management
- Services: External service integrations
- Middleware: Security and logging middleware
- Configuration: App configuration and encryption
- Storage: Data persistence layer
- Go 1.24 or later
- Docker and Docker Compose
- Redis (for session management)
- Twilio account (for SMS)
- Clone the repository:
git clone https://github.com/lmousom/passless-auth.git
cd passless-auth- Install dependencies:
go mod tidy- Set up encryption:
# Generate encryption key
./scripts/manage-keys.sh generate
# Set the encryption key
export PASSLESS_ENCRYPTION_KEY='your-generated-key'- Start the services:
docker-compose up --buildexport PASSLESS_SERVER_PORT=8080
export PASSLESS_JWT_SECRET=your-secret
export PASSLESS_SMS_ACCOUNT_SID=your-sid
export PASSLESS_ENCRYPTION_KEY=your-encryption-keySee config/config.yaml for detailed configuration options.
- AES-GCM encryption for sensitive values
- Rate limiting (20 requests/minute)
- Secure headers (HSTS, CSP, XSS)
- JWT-based session management
- Secure OTP generation
- Encrypted configuration
- SMS-based OTP delivery
- Never commit encryption keys
- Use different keys per environment
- Regular key rotation
- Monitor access attempts
- Keep dependencies updated
POST /api/v1/sendOtp- Send OTPPOST /api/v1/verifyOtp- Verify OTPPOST /api/v1/2fa/enable- Enable 2FAPOST /api/v1/2fa/verify- Verify 2FAGET /api/v1/login- Check auth statusPOST /api/v1/refreshToken- Refresh tokenPOST /api/v1/logout- Logout
Import passless-auth.postman_collection.json for API testing.
- Start dependencies:
docker-compose up -d redis prometheus otel-collector- Run the application:
go run cmd/server/main.godocker-compose up --buildMIT License - See LICENSE for details
