feat: Implement audit logging and rate limiting middleware with SurrealDB integration
- Added audit logging middleware to track admin actions and save logs to SurrealDB. - Introduced rate limiting middleware for public endpoints and authentication endpoints. - Enhanced security headers middleware with nonce generation for CSP in development. - Created utility functions for extracting real client IP addresses from headers. - Updated Cargo.toml and Cargo.lock to include new dependencies. - Added new schemas for audit logs and rate limiting in the entities module. - Refactored permissions middleware to support new permission checks.
This commit is contained in:
@@ -51,6 +51,10 @@ pub enum ResourceEnum {
|
||||
HackathonTimeline,
|
||||
/// Hackathon submissions table for project submissions
|
||||
HackathonSubmissions,
|
||||
/// Rate limiting table for IP-based rate limiting
|
||||
RateLimit,
|
||||
/// Audit log table for admin action tracking
|
||||
AuditLog,
|
||||
}
|
||||
|
||||
impl fmt::Display for ResourceEnum {
|
||||
@@ -76,6 +80,8 @@ impl fmt::Display for ResourceEnum {
|
||||
ResourceEnum::HackathonEvents => "app_hackathon_events",
|
||||
ResourceEnum::HackathonTimeline => "app_hackathon_timeline",
|
||||
ResourceEnum::HackathonSubmissions => "app_hackathon_submissions",
|
||||
ResourceEnum::RateLimit => "app_rate_limit",
|
||||
ResourceEnum::AuditLog => "app_audit_log",
|
||||
};
|
||||
write!(f, "{}", table_name)
|
||||
}
|
||||
@@ -116,6 +122,8 @@ impl ResourceEnum {
|
||||
ResourceEnum::HackathonEvents => "app_hackathon_events",
|
||||
ResourceEnum::HackathonTimeline => "app_hackathon_timeline",
|
||||
ResourceEnum::HackathonSubmissions => "app_hackathon_submissions",
|
||||
ResourceEnum::RateLimit => "app_rate_limit",
|
||||
ResourceEnum::AuditLog => "app_audit_log",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user