Skip to content

Commit eaa06e4

Browse files
committed
add docs
1 parent 5ae8628 commit eaa06e4

File tree

1 file changed

+7
-110
lines changed

1 file changed

+7
-110
lines changed

docs/ip_filtering.md

Lines changed: 7 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# IP Filtering
22

3-
The Hooks service provides comprehensive application-level IP filtering functionality that allows you to control access to your webhooks based on client IP addresses. This feature supports both allowlist (whitelist) and blocklist (blacklist) configurations with CIDR notation support.
3+
The Hooks service provides comprehensive application-level IP filtering functionality that allows you to control access to your webhooks based on client IP addresses. This feature supports both allowlist and blocklist configurations with CIDR notation support.
44

55
## Overview
66

@@ -38,6 +38,8 @@ ip_filtering:
3838
3939
Configure IP filtering for specific endpoints:
4040
41+
> If a global configuration is set, endpoint-level settings will override it.
42+
4143
```yaml
4244
# config/endpoints/secure-endpoint.yml
4345
path: /secure-webhook
@@ -55,17 +57,20 @@ ip_filtering:
5557
## Configuration Options
5658
5759
### `ip_header` (optional)
60+
5861
- **Default**: `X-Forwarded-For`
5962
- **Description**: HTTP header to check for the client IP address
6063
- **Common alternatives**: `X-Real-IP`, `CF-Connecting-IP`, `X-Client-IP`
6164

6265
### `allowlist` (optional)
66+
6367
- **Type**: Array of strings
6468
- **Description**: List of allowed IP addresses or CIDR ranges
6569
- **Behavior**: If specified, only IPs in this list are allowed access
6670
- **Format**: Individual IPs (`192.168.1.1`) or CIDR notation (`192.168.1.0/24`)
6771

6872
### `blocklist` (optional)
73+
6974
- **Type**: Array of strings
7075
- **Description**: List of blocked IP addresses or CIDR ranges
7176
- **Behavior**: IPs in this list are denied access, even if they appear in the allowlist
@@ -167,7 +172,7 @@ When IP filtering fails, the service returns an HTTP 403 Forbidden response:
167172
{
168173
"error": "ip_filtering_failed",
169174
"message": "IP address not allowed",
170-
"request_id": "550e8400-e29b-41d4-a716-446655440000"
175+
"request_id": "<uuid>"
171176
}
172177
```
173178

@@ -188,111 +193,3 @@ curl -H "X-Forwarded-For: 192.168.1.100" \
188193
-d '{"test": "data"}' \
189194
http://localhost:8080/webhooks/secure-endpoint
190195
```
191-
192-
## Common Use Cases
193-
194-
### 1. Restrict to Corporate Network
195-
196-
```yaml
197-
ip_filtering:
198-
allowlist:
199-
- "10.0.0.0/8" # Private network
200-
- "172.16.0.0/12" # Private network
201-
- "192.168.0.0/16" # Private network
202-
```
203-
204-
### 2. Allow Specific Service Providers
205-
206-
```yaml
207-
ip_filtering:
208-
allowlist:
209-
- "140.82.112.0/20" # GitHub webhook IPs (example)
210-
- "192.30.252.0/22" # GitHub webhook IPs (example)
211-
```
212-
213-
### 3. Block Known Bad Actors
214-
215-
```yaml
216-
ip_filtering:
217-
blocklist:
218-
- "203.0.113.0/24" # Example bad network
219-
- "198.51.100.50" # Specific bad IP
220-
```
221-
222-
### 4. Development vs Production
223-
224-
```yaml
225-
# Development - allow local testing
226-
ip_filtering:
227-
allowlist:
228-
- "127.0.0.1"
229-
- "192.168.1.0/24"
230-
231-
# Production - restrict to known sources
232-
ip_filtering:
233-
allowlist:
234-
- "10.0.0.0/8"
235-
blocklist:
236-
- "10.0.0.100" # Compromised internal host
237-
```
238-
239-
## Best Practices
240-
241-
1. **Start Restrictive**: Begin with a narrow allowlist and expand as needed
242-
2. **Monitor Logs**: Watch for legitimate traffic being blocked
243-
3. **Layer Security**: Use IP filtering alongside other security measures
244-
4. **Document Changes**: Keep track of why specific IPs or ranges are allowed/blocked
245-
5. **Regular Review**: Periodically review and update your IP filtering rules
246-
6. **Test Thoroughly**: Always test configuration changes in a non-production environment first
247-
7. **Consider Automation**: For dynamic environments, consider using network-level controls instead
248-
249-
## Troubleshooting
250-
251-
### Common Issues
252-
253-
1. **Wrong IP Header**: Verify your proxy/load balancer sets the correct IP header
254-
2. **CIDR Notation**: Ensure CIDR ranges are correctly formatted
255-
3. **Header Case**: The service performs case-insensitive header lookup
256-
4. **Multiple IPs**: Only the first IP in comma-separated headers is checked
257-
5. **IPv6 Support**: The service supports IPv6 addresses and ranges
258-
259-
### Debug Steps
260-
261-
1. Check server logs for IP filtering messages
262-
2. Verify the client IP being detected matches expectations
263-
3. Test with known good/bad IPs
264-
4. Confirm endpoint vs global configuration precedence
265-
5. Validate CIDR range calculations
266-
267-
## Performance Considerations
268-
269-
- IP filtering adds minimal overhead to request processing
270-
- CIDR matching is optimized for common use cases
271-
- Consider the number of rules - hundreds of rules may impact performance
272-
- Invalid IP patterns in configuration are silently skipped
273-
274-
## Migration from Auth Plugins
275-
276-
If you're currently using custom auth plugins for IP filtering, you can migrate to the built-in IP filtering feature:
277-
278-
**Before (Custom Auth Plugin):**
279-
```yaml
280-
path: /webhook
281-
handler: my_handler
282-
auth:
283-
type: my_ip_filtering_plugin
284-
opts:
285-
allowed_ips:
286-
- "192.168.1.1"
287-
```
288-
289-
**After (Built-in IP Filtering):**
290-
```yaml
291-
path: /webhook
292-
handler: my_handler
293-
ip_filtering:
294-
allowlist:
295-
- "192.168.1.1"
296-
```
297-
298-
The built-in IP filtering provides better performance, more features (CIDR support, blocklists), and consistent error handling across all endpoints.

0 commit comments

Comments
 (0)