shahzadbarkati/role-based-jwt-auth
tymon/jwt-auth (a battle-tested foundation) while adding role-based granularity.users table and passwords table. Custom user models or auth systems may require significant refactoring.users table.@role('admin')) integrates seamlessly with Laravel’s built-in middleware stack.HasJwtAuth trait or overriding migrations.PasswordReset service.app_users), migrations may conflict.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Token Leakage | High | Enforce HTTPS; use same-site cookies for refresh tokens. |
| Role Logic Errors | Medium | Unit-test role middleware with edge cases (e.g., overlapping roles). |
| Performance | Medium | Benchmark token blacklisting (database vs. Redis). |
| Vendor Lock-in | Low | Package is MIT-licensed; core logic is reusable. |
| Laravel 12 Breaking Changes | Low | Monitor Laravel updates; package is actively maintained (per README). |
users table custom? If so, can the package’s migrations be adapted, or will a fork be needed?Auth facade patterns./api/login).can:admin with @role('admin')).config('jwt-auth.enabled')).| Component | Compatibility Notes |
|---|---|
| Laravel 12 | Fully supported; leverages Laravel’s new features (e.g., app models). |
| PHP 8.2+ | No issues expected; uses modern syntax (e.g., named arguments). |
| Databases | MySQL/PostgreSQL/SQLite supported; migrations are schema-agnostic. |
| Mail Drivers | SMTP/Mailgun/Postmark supported; custom drivers require MailManager extension. |
| Existing Auth | Conflicts possible with tymon/jwt-auth or laravel/sanctum. Uninstall old packages first. |
| Custom User Models | Requires extending HasJwtAuth trait or overriding migrations. |
| API Gateways | Works with Kong, AWS API Gateway, etc., but token validation must be handled upstream if using JWT. |
AuthServiceProvider to use the package’s guard./api/auth/login with package’s routes (defined in routes/api.php).Authorization: Bearer {token}).roles table (if using many-to-many).@role() directives.jwt_auth.token_invalidated).config/jwt-auth.php.tymon/jwt-auth and Laravel core are required.JwtAuthException).jwt_auth.login and jwt_auth.token_refreshed are emitted.config['token_storage']).How can I help you explore Laravel packages today?