The accessControl plugin lets you restrict who can call your APIs. Rules can match the client by IP address (IPv4/IPv6, optional CIDR) or by hostname (regex). Rules are evaluated top to bottom. The first matching rule decides. If nothing matches, access is denied.
- Start Membrane from this directory:
or on Windows:
./membrane.sh
membrane.cmd
- Call the API on port 2000 (allowed for everyone):
curl http://localhost:2000/
- Call
/products(allowed on localhost):curl http://localhost:2000/products
- Call
/vendors(denied for localhost):curl http://localhost:2000/vendors
- Open the
apis.yamlfile to see how the three API routes are defined and howaccessControlis applied per route.
Notes:
- Hostname rules are regexes matched against the peer hostname (resolved only when hostname rules exist).
- IP rules support CIDR (e.g.,
10.0.0.0/8,2001:db8::/64), and work for both IPv4 and IPv6.
See: