Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request: Implement Rate Limiting
Closes #175
🚦 Overview
This PR implements comprehensive rate limiting for course and user creation operations to protect against spam attacks as requested in issue #175.
📋 Changes Made
Core Features
Files Modified
User Management Contract
src/schema.rs- AddedRateLimitConfig,RateLimitDatastructures and storage keyssrc/error.rs- AddedRateLimitExceededandRateLimitNotConfigurederror typessrc/functions/utils/rate_limit_utils.rs- NEW Rate limiting validation logicsrc/functions/utils/mod.rs- NEW Utils module exportssrc/functions/mod.rs- Export utils modulesrc/functions/create_user_profile.rs- Integrated rate limiting validationsrc/functions/admin_management.rs- Auto-initialize default rate limit configsrc/functions/delete_user.rs- Updated admin config structure in testssrc/functions/utils/storage_utils.rs- Simplified for Soroban compatibilityCourse Registry Contract
src/schema.rs- AddedCourseRateLimitConfig,CourseRateLimitDatastructuressrc/error.rs- AddedCourseRateLimitExceededandCourseRateLimitNotConfiguredsrc/functions/course_rate_limit_utils.rs- NEW Course rate limiting utilitiessrc/functions/mod.rs- Export course rate limit utilssrc/functions/create_course.rs- Integrated rate limiting validationsrc/functions/access_control.rs- Auto-initialize course rate limitingsrc/functions/edit_prerequisite.rs- Configured permissive limits for complex tests🛡️ Security Features
Rate Limiting Logic
Automatic Window Management
Error Handling
Error(Contract, #26)- User rate limit exceededError(Contract, #32)- Course rate limit exceeded🧪 Testing
Compatibility
Integration
📊 Impact
Before
After
🚀 Deployment
The rate limiting system is production-ready and will be automatically active upon deployment with these default settings:
Ready for review and merge! 🎉