Add SMTP authentication failure blocking system with admin dashboard#66
Merged
lucaforni merged 1 commit intoFeb 1, 2026
Merged
Conversation
This commit implements a comprehensive system to protect against brute force attacks on SMTP authentication by automatically blocking IPs after repeated failed authentication attempts. Features: - Automatic IP blocking after X failed auth attempts (default: 5, configurable) - Configurable block duration Y minutes (default: 120, configurable) - Blocks persist across all SMTP auth methods (PLAIN, LOGIN, CRAM-MD5) - Counter resets automatically on successful authentication - Admin web dashboard to view, search, and manage blocked IPs - Manual block/unblock capabilities for individual or all IPs - Prometheus metrics integration for monitoring - Detailed logging for security auditing Technical Implementation: - AuthFailureTracker class manages blocking logic using Rails.cache - SHA-256 hashed cache keys for security - Efficient indexing system for listing blocked IPs - RESTful admin routes for IP management - HAML-based responsive UI integrated with existing admin interface Testing: - 39 unit tests for AuthFailureTracker - 14 integration tests for SMTP client auth blocking - 7 controller tests for admin dashboard - All 60 new tests passing Configuration (via postal.yml or environment variables): - smtp_server.auth_failure_threshold (default: 5) - smtp_server.auth_failure_block_duration (default: 120 minutes) Documentation: - Complete user guide (doc/SMTP_AUTH_BLOCKING.md) - Configuration examples for various security levels - Technical documentation for developers - Updated main configuration documentation Files Modified: - app/lib/smtp_server/client.rb - Integrated blocking checks - app/views/layouts/application.html.haml - Added menu link - config/routes.rb - Added admin routes - lib/postal/config_schema.rb - Added configuration options - doc/config/configuration.md - Documented new feature Files Created: - app/lib/smtp_server/auth_failure_tracker.rb (323 lines) - app/controllers/admin_blocked_ips_controller.rb (74 lines) - app/views/admin_blocked_ips/index.html.haml (118 lines) - 3 comprehensive test files (520+ lines) - 3 documentation files
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.
This commit implements a comprehensive system to protect against brute force attacks on SMTP authentication by automatically blocking IPs after repeated failed authentication attempts.
Features:
Technical Implementation:
Testing:
Configuration (via postal.yml or environment variables):
Documentation:
Files Modified:
Files Created: