Add API Key Access Restrictions #5796
Draft
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.
Summary
This PR introduces advanced access control features for API keys as part of the Enterprise Edition, allowing administrators to restrict API key usage based on IP addresses, HTTP referrers, and rate limits.
Features Added
"allowed_ips": ["192.168.1.0/24", "10.0.0.1/32"]
"allowed_referrers": ["*.example.com", "https://trusted.org/*"]
"rate_limit": { "max_requests": 100, "window_seconds": 3600 }
X-RateLimit-Limit
,X-RateLimit-Remaining
,X-RateLimit-Reset
Technical Implementation
Core Components
api_key_restrictions.rs
: Core validation logic for IP and referrer restrictions with comprehensive wildcard matching and CIDR subnet supportredis-rate-limiter
is activated and the env variableMEILI_REDIS_RATE_LIMIT_URL
is set.API Changes
rate_limit_exceeded
(HTTP 429)Testing
Example Usage
Migration & Compatibility
Security Considerations
browser-based applications
Performance Impact
Breaking Changes
None - all new fields are optional and backward compatible.
Dependencies Added
Enterprise Edition Notice
This feature is part of Meilisearch Enterprise Edition and is governed by the Business Source License 1.1.
Check