Auth4Free
A modern, secure, and easy-to-use authentication library for Rust applications.
๐ Features
- Password Validation - Robust password strength checking and validation
- JWT Authentication - Secure token-based authentication
- Password Hashing - Industry-standard bcrypt password hashing
- User Management - Complete user lifecycle management
- Session Management - Secure session handling with refresh tokens
- Rate Limiting - Brute force protection with configurable limits โจ NEW in v0.2.0
- Multi-Factor Authentication - Enhanced security (planned)
- OAuth2 Integration - Social login support (planned)
๐ฆ Installation
Add this to your Cargo.toml:
[]
= "0.2.0"
๐ง Quick Start
Password Validation
use *;
let config = default;
let password = "MySecureP@ssw0rd!";
match validate_password
// Check password strength
let score = password_strength_score;
let category = password_strength_category;
println!;
User Authentication with Rate Limiting
use authenticate_user;
use RateLimiter;
use RateLimitConfig;
use User;
async
Session Management
use SessionManager;
use Uuid;
use Duration;
async
Rate Limiting
use ;
use Duration;
// Configure rate limiting
let config = RateLimitConfig ;
let limiter = new;
// Check if IP is allowed to attempt login
match limiter.check_rate_limit.await
๐ก๏ธ Security Features
Password Validation Rules
- Minimum length requirements
- Uppercase/lowercase letter requirements
- Number and special character requirements
- Consecutive character limits
- Common password detection
Password Strength Analysis
use *;
let passwords = vec!;
for pwd in passwords
๐ Examples
Check out the examples directory for complete working examples:
password_validation- Basic password validationuser_registration- Complete user registration flowweb_api_integration- Web framework integration- [
session_integration] [examples\session_integration.rs] - Session management with auth
Run examples with:
๐งช Testing
Run all tests:
๐ฎ Future Features
Coming Soon
- Multi-Factor Authentication (MFA)
- OAuth2 Provider Integration (Google, GitHub, etc.)
- Email Verification System
- Role-Based Access Control (RBAC)
Planned Features
- Account Lockout Mechanisms
- Refresh Token System
- Rate Limiting and Brute Force Protection (โ Added in v0.2.0)
- Audit Logging
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with security best practices in mind
- Inspired by industry standards for authentication systems
- Development assisted by AI pair programming tools
Made with โค๏ธ for the Rust community