[SECURITY] Add IP allowlist/denylist per project — restrict API access to specific IP ranges for enhanced access control
Problem
Projects currently accept API requests from any IP address globally. For enterprise users, internal tools, or sensitive applications, this is a security risk — leaked API keys can be used from anywhere. There is no mechanism to restrict API access to specific IP ranges (e.g., office VPN, cloud VPC, home network).
Proposed Improvement
Add project-level IP access control that allows owners to configure allowlists and denylists for API key usage. The feature should:
- Support CIDR notation (e.g.,
192.168.1.0/24,10.0.0.0/8) and individual IPs - Evaluate IP restrictions on every API request before rate limiting and auth
- Default to "allow all" if no rules are configured (backward compatible)
- Support both allowlist mode (block everything except listed) and denylist mode (allow everything except listed)
- Return
403 ForbiddenwithX-Blocked-By-IP-Policy: trueheader when blocked - Log all IP policy violations to the audit trail
- Show IP rules in dashboard with visual CIDR validator and conflict detection
Expected Impact
- Better security for enterprise and sensitive projects
- Reduced blast radius from leaked API keys
- Improved compliance with corporate network policies
- Better long-term scalability with enterprise-grade access control
Possible Implementation
- Add
IpAccessRulemodel inpackages/common/models/with fields:projectId,cidr,type('allow' | 'deny'),mode('allowlist' | 'denylist'),description - Add
ipAccessControlmiddleware inapps/public-api/middleware/evaluatingreq.ipagainst rules - Add
POST /api/projects/{id}/ip-rules,GET,DELETEendpoints in dashboard-api - Use
ip-range-checkornetmasklibrary for CIDR matching - Add dashboard UI: IP rule table, CIDR validator with live preview, mode toggle
- Update
docker-compose.ymlto includeTRUSTED_PROXY_COUNTfor accurateX-Forwarded-Forparsing - Write tests for CIDR matching, allowlist/denylist logic, header spoofing attempts, and bypass scenarios
I'm GSSoC'26 contributor, Please assign this task to me!
/assign
Hi! This issue appears to be unassigned. Would it be possible to assign it to me for GSSoC '26? I'm interested in working on this and would be happy to submit a PR once assigned.
Thank you!
pls assign this to me under gssoc