-
Notifications
You must be signed in to change notification settings - Fork 0
Feature rate limiting #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
adcc0eb
feat(auth): introduce rate limit service interface
fulleni 484d7db
feat(rate-limit): implement MongoDB-backed rate limit service
fulleni 6efac46
feat(rate-limiting): implement rate limiting service
fulleni 2f82e09
feat(database): add rate limit attempts TTL and key indexes
fulleni 167af20
feat(middlewares): implement rate limiter middleware
fulleni b7e6faa
fix(error_handler): map rate limiting errors to 429 status code
fulleni c889ba4
feat(routes): add rate limit service to middleware
fulleni d2c8e7e
feat(auth): add rate limiting to request-code endpoint
fulleni c19ec59
lint: misc
fulleni f09468f
chore(env): add rate limiting configuration variables
fulleni 9453122
feat(config): add rate limit configuration parameters
fulleni 65f76a2
refactor(auth): move request-code handler to index.dart and apply rat...
fulleni 9fd3a44
feat(auth): add rate limiting middleware to request code endpoint
fulleni 17df05c
style(auth): remove extra whitespace in request-code handler
fulleni 6134a81
feat(rbac): add rate limiting bypass permission
fulleni baec763
feat(api): implement rate limiting for data routes
fulleni 8f7a85a
refactor(routes): remove redundant middleware documentation
fulleni cd5e29b
docs(env): clarify rate limiting configuration in .env.example
fulleni 0377190
docs(README): add built-in API rate limiting features
fulleni 17fc972
fix(config): update default JWT expiry hours to 1 month
fulleni 0bab60d
docs(env): update JWT expiry default and admin configuration
fulleni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(auth): add rate limiting middleware to request code endpoint
- Implement rate limiting specifically for the `/api/v1/auth/request-code` endpoint - Use custom rate limit configuration from EnvironmentConfig - Apply rateLimiter middleware with ipKeyExtractor for key generation
- Loading branch information
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
routes/api/v1/auth/request-code/_middleware.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import 'package:dart_frog/dart_frog.dart'; | ||
| import 'package:flutter_news_app_api_server_full_source_code/src/config/environment_config.dart'; | ||
| import 'package:flutter_news_app_api_server_full_source_code/src/middlewares/rate_limiter_middleware.dart'; | ||
|
|
||
| /// This middleware applies a rate limit specifically to the | ||
| /// `/api/v1/auth/request-code` endpoint. | ||
| Handler middleware(Handler handler) { | ||
| return handler.use( | ||
| rateLimiter( | ||
| limit: EnvironmentConfig.rateLimitRequestCodeLimit, | ||
| window: EnvironmentConfig.rateLimitRequestCodeWindow, | ||
| keyExtractor: ipKeyExtractor, | ||
| ), | ||
| ); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.