laraditz/user-security
Adds user security features for Laravel/Lumen: security PIN, mnemonic key validation/storage, and 2FA support. Includes a UserSecurable trait, SecureUser facade, and configurable hashing key (LUS_KEY) for one-way encryption.
Auth, Hash, Encryption) for seamless integration. Assumes standard Laravel user model structure (e.g., users table with email, password).Auth facade (for user retrieval).Hash and Encryption helpers (for secure storage).Redis or Database for 2FA token storage (configurable).security_pin, mnemonic_key, two_factor_secret, etc.) to the users table. Risk: Schema changes may conflict with existing customizations (e.g., polymorphic auth).config/user-security.php, but lacks examples for edge cases (e.g., multi-tenant environments).App\Models\User)? If using a custom model (e.g., App\Models\Customer), integration may require middleware or trait overrides.PragmaRX\Google2FA (common) or a custom implementation? No clear fallback if the library is missing.auth:api)? Will it override or extend the flow?UserSecurityManager).UserSecurity::verifyPin()).TwoFactorVerified).illuminate/support, illuminate/auth (core).pragma/laravel-google2fa (for TOTP; may need manual install if missing).redis (for token caching; configurable).users table schema before migrations.composer require laraditz/user-security.php artisan vendor:publish --provider="Laraditz\UserSecurity\UserSecurityServiceProvider".php artisan migrate (package includes schema updates).config/app.php (or rely on auto-discovery for Laravel ≥5.5).config/user-security.php (e.g., pin length, 2FA algorithms).UserSecurity facade methods (e.g., generatePin(), verifyTwoFactor()).App\Models\Customer), extend the package’s UserSecurityServiceProvider to bind the correct model.$this->app->bind(
Laraditz\UserSecurity\Contracts\UserSecurityUser::class,
App\Models\Customer::class
);
failed_two_factor_attempt events).pragma/laravel-google2fa (if used) for updates/breaking changes.composer.json until maturity improves.user-security.php settings (e.g., pin complexity rules) in a config management tool (e.g., Laravel Forge, Envoyer).security_pin, mnemonic_key) in DB diagrams.users.security_pin column exists and is hashed.UserSecurity logging in config/user-security.php.UserSecurity::generatePin(); // Test pin generation
UserSecurity::verifyTwoFactor('123456'); // Test 2FA
Google2FA is cached (e.g., Redis) to avoid DB hits.security_pin, two_factor_secret) if used in queries.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Database migration |
How can I help you explore Laravel packages today?