Its been a while
This commit is contained in:
@@ -115,7 +115,7 @@ POST /api/v1/logout
|
||||
Authorization: Bearer <your_access_token>
|
||||
```
|
||||
|
||||
blacklists the current token (real logout, token becomes invalid)
|
||||
retires the current token (real logout, token becomes invalid)
|
||||
|
||||
## 👥 role-based authorization
|
||||
|
||||
@@ -146,7 +146,7 @@ end
|
||||
## 🔒 security features
|
||||
|
||||
* **no secret fallbacks**: JWT_SECRET_KEY must be set (crashes if missing)
|
||||
* **token blacklisting**: logout actually invalidates tokens
|
||||
* **token retireing**: logout actually invalidates tokens
|
||||
* **refresh tokens**: short-lived access tokens (1 hour) + long-lived refresh tokens (7 days)
|
||||
* **rate limiting**: login, signup, and refresh endpoints are throttled
|
||||
* **JTI tracking**: every token has a unique identifier for precise control
|
||||
@@ -176,8 +176,8 @@ rspec
|
||||
add these to your scheduled jobs (sidekiq, cron, etc):
|
||||
|
||||
```ruby
|
||||
# clean up expired blacklisted tokens
|
||||
BlacklistedToken.cleanup_expired
|
||||
# clean up expired retired tokens
|
||||
RetiredToken.cleanup_expired
|
||||
|
||||
# clean up old refresh tokens
|
||||
RefreshToken.cleanup_old_tokens
|
||||
@@ -196,8 +196,8 @@ REDIS_URL=your_redis_url (optional, for rack-attack)
|
||||
### database indexes
|
||||
|
||||
migrations include proper indexes for performance:
|
||||
* `blacklisted_tokens.jti` (unique)
|
||||
* `blacklisted_tokens.exp`
|
||||
* `retired_tokens.jti` (unique)
|
||||
* `retired_tokens.exp`
|
||||
* `refresh_tokens.token` (unique)
|
||||
* `refresh_tokens.user_id + revoked`
|
||||
* `users.role`
|
||||
@@ -210,7 +210,7 @@ open issues or pull requests.
|
||||
## ✨ features
|
||||
|
||||
* ✅ JWT authentication with secure token generation (includes JTI for tracking)
|
||||
* ✅ Token blacklisting for real logout (tokens are invalidated on logout)
|
||||
* ✅ Token retireing for real logout (tokens are invalidated on logout)
|
||||
* ✅ Refresh tokens (7-day expiry, keeps users logged in securely)
|
||||
* ✅ Role-based authorization (user, moderator, admin roles)
|
||||
* ✅ Rate limiting with Rack::Attack (prevents brute force attacks)
|
||||
@@ -232,7 +232,7 @@ feel free to fork, star, share, or improve.
|
||||
|
||||
## ⚠️ disclaimer
|
||||
|
||||
this template includes production-grade features like token blacklisting, refresh tokens, and role-based auth.
|
||||
this template includes production-grade features like token retireing, refresh tokens, and role-based auth.
|
||||
however, you should still:
|
||||
* review security settings for your specific use case
|
||||
* set up proper monitoring and logging
|
||||
|
||||
Reference in New Issue
Block a user