You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: Implement IP-based access control
Add IpAccessControl for whitelist/blacklist connection filtering:
- Support CIDR notation for IP ranges (IPv4 and IPv6)
- Whitelist mode: only allow specified IP ranges
- Blacklist mode: block specific IP ranges
- Blacklist takes priority over whitelist
- Dynamic updates: block/unblock IPs at runtime
- Thread-safe SharedIpAccessControl for shared access
- Integration at connection level before handler creation
Configuration:
- allowed_ips: CIDR ranges for whitelist mode
- blocked_ips: CIDR ranges always denied
Features:
- 14 comprehensive unit tests for access control
- Rejected connections get minimal handler that rejects auth
- Logging for blocked/allowed connections
- Reloadable configuration support
Closes#141
* fix: Use fail-closed behavior for IP access control lock contention
* docs: Add IP access control documentation and apply code formatting
- Document IpAccessControl feature in ARCHITECTURE.md
- Add detailed IP access control section to server-configuration.md
- Describe whitelist/blacklist modes and priority rules
- Include CIDR notation examples
- Document runtime update capability and security behavior
- Apply rustfmt formatting to access.rs and mod.rs
Copy file name to clipboardExpand all lines: docs/architecture/server-configuration.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,15 +193,46 @@ security:
193
193
idle_timeout: 3600# Default: 3600 (1 hour)
194
194
195
195
# IP allowlist (CIDR notation, empty = allow all)
196
+
# When configured, only connections from these ranges are allowed
196
197
allowed_ips:
197
198
- "192.168.1.0/24"
198
199
- "10.0.0.0/8"
199
200
200
201
# IP blocklist (CIDR notation)
202
+
# Connections from these ranges are always denied
203
+
# Blocked IPs take priority over allowed IPs
201
204
blocked_ips:
202
205
- "203.0.113.0/24"
203
206
```
204
207
208
+
### IP Access Control
209
+
210
+
The server supports IP-based connection filtering through `allowed_ips` and `blocked_ips` configuration options:
211
+
212
+
**Modes of Operation:**
213
+
214
+
1. **Default Mode** (no `allowed_ips` configured): All IPs are allowed unless explicitly blocked
215
+
2. **Whitelist Mode** (`allowed_ips` configured): Only IPs matching allowed ranges can connect
216
+
217
+
**Priority Rules:**
218
+
- Blocked IPs always take priority over allowed IPs
219
+
- If an IP matches both `allowed_ips` and `blocked_ips`, the connection is denied
220
+
- Connections from blocked IPs are rejected before authentication
221
+
222
+
**CIDR Notation Examples:**
223
+
- `10.0.0.0/8`- All 10.x.x.x addresses (Class A private network)
224
+
- `192.168.1.0/24`- All 192.168.1.x addresses
225
+
- `192.168.100.50/32`- Single IP address (192.168.100.50)
226
+
- `2001:db8::/32`- IPv6 prefix
227
+
228
+
**Runtime Updates:**
229
+
The IP access control supports dynamic updates at runtime through the `SharedIpAccessControl` API, allowing administrators to block or unblock IPs without restarting the server.
230
+
231
+
**Security Behavior:**
232
+
- Connections from blocked IPs are rejected at the connection level before any authentication attempt
233
+
- On lock contention (rare), the system defaults to DENY for fail-closed security
234
+
- All access control decisions are logged for auditing
235
+
205
236
## Environment Variable Overrides
206
237
207
238
The following environment variables can override configuration file settings:
0 commit comments