Access rules
Access rules decide which nodes can reach which. Each node checks the rules for each stream and each flow that comes to it, with the caller’s identity from the controller. The check also works while the controller is offline.
Edit the rules in the console (Access rules), or send them with POST /api/v1/saas/acls (refer to the console API).
How rules apply
Section titled “How rules apply”- Deny by default. A request that no rule allows is refused.
- In order. The first rule that matches decides.
- A policy that cannot be parsed refuses everything. The console checks each rule before it saves it.
- Who sees whom. A node lists only the peers that the rules let it reach, or be reached by.
The shape of a rule
Section titled “The shape of a rule”allow|deny src:<who> dst:<what> port:<n> proto:tcp|udp|icmpany or * means any value. src:, dst:, port: and proto: each appear at most once.
| Part | Takes | Joined with |
|---|---|---|
src: |
Label selectors; at most one person or team (user:<email>, team:<name>, an autogroup); at most one node:<node ID> |
+: all must match |
dst: |
Label selectors; at most one node:<node ID>; autogroup:self. Or one node name, service name or address, alone |
+: all must match |
port: |
A port (443), a list (22,80,443), a range (8000-8099), a mix (22,8000-8099), or any. At most 64 items. |
|
proto: |
tcp, udp, icmp or any |
+in one side means AND:src:autogroup:admin+os:managedis an Owner or Admin, on a node with the labelos:managed.- Two rules mean OR.
In the console’s rule editor, a side with two or more labels shows how they combine:
| Choice | The labels | What the editor saves |
|---|---|---|
| all of these (the default) | A node needs every label | One rule: dst:role:web+role:api |
| any of these | A node needs one of the labels | One rule for each label: dst:role:web, then dst:role:api |
- With “any of these” on both sides, the editor saves one rule for each pair of labels, at most 20.
- The rules are independent after the save. Each one is a row in the list.
Autogroups
Section titled “Autogroups”An autogroup is a group that ZQX keeps for you. You do not list its members.
| Autogroup | Side | Matches |
|---|---|---|
autogroup:member |
src: |
A node where a person is logged in. Any person of the xnet. |
autogroup:admin |
src: |
A node where an Owner or an Admin of the xnet is logged in. |
autogroup:owner |
src: |
A node where an Owner of the xnet is logged in. |
autogroup:self |
dst: |
A node where the same person as the caller is logged in: “each person reaches their own nodes”. |
The table shows which caller each autogroup lets in.
| Caller | autogroup:member |
autogroup:admin |
autogroup:owner |
dst:autogroup:self (destination: Ann’s node) |
|---|---|---|---|---|
| Ann (Owner), logged in on her laptop | Yes | Yes | Yes | Yes |
| Bo (Admin), logged in on his laptop | Yes | Yes | No | No |
| Cy (Member), logged in on her laptop | Yes | No | No | No |
| A server with labels and no person | No | No | No | No |
Examples:
# Owners and Admins reach the production servers on SSH.allow src:autogroup:admin dst:env:prod port:22 proto:tcp
# Each person reaches their own nodes, on any port.allow src:autogroup:member dst:autogroup:self port:any proto:any
# Each person reaches their own nodes that have the label os:managed.allow src:autogroup:member dst:autogroup:self+os:managed port:any proto:anyA team names a set of the xnet’s people once. Create teams on the Members page (Teams), and name them in rules with team:<name>.
# The eng team reaches production over SSH, from managed laptops.allow src:team:eng+os:managed dst:env:prod port:22 proto:tcp- Members are people of the xnet. A person who leaves the xnet leaves its teams.
- A person is needed. A team matches only a node where one of its members is logged in.
- One person or team in each rule. For two teams, write two rules.
- A team that a rule names can’t be deleted. Change those rules first.
- Changes reach the nodes within about 30 seconds.
- Groups of nodes are labels, not teams:
env:prodis every node with that label. teamis a rule word, so it is not a label namespace.- A controller without the SaaS gets teams only with the management scope
loginorfull, as for the roles.
One rule can name several ports:
# Web servers on HTTP and HTTPS.allow src:autogroup:member dst:role:web port:80,443 proto:tcp
# A range of development ports, and SSH.allow src:role:dev dst:env:dev port:22,8000-8099 proto:tcp- The ports are kept in order, and overlapping ranges are joined:
8050-8200,8000-8099is saved as8000-8200. - A range goes from low to high.
8099-8000is refused, with the fix.
What to know:
- A person is needed. Every autogroup matches only a node where a person is logged in. A node that joined with a key and has no person never matches. Give such nodes labels, and write rules on the labels.
- Roles come from the console. The roles are the ones on the Members page. A change reaches the nodes within about 30 seconds.
autogroup:adminincludes Owners. An Owner can do what an Admin can.autogroup:selfis a destination only. It compares the destination’s person with the caller’s person. Insrc:it is refused, with the fix.- A shared machine. While a person is logged in on a machine, that machine is theirs for
autogroup:self. - A controller without the SaaS. A self-hosted controller learns the roles from the SaaS only when its management scope is
loginorfull(ZQX_SAAS_MANAGEMENT; refer to Run your own controller). With the scopereadoroff,autogroup:adminandautogroup:ownermatch nobody.
Errors
Section titled “Errors”A word that is not part of a rule is an error, not ignored. The error names the rule and gives the fix. Examples:
| You write | You get |
|---|---|
port 443 (no colon), prt:443, protocol:tcp |
A refusal, with the right form |
port:8099-8000, port:70000, port:22, |
A refusal that says how to write a port, a list or a range |
src:autogroup:self |
“autogroup:self is a destination”, with an example |
src:autogroup:admin+user:ann@acme.example, src:team:eng+team:ops |
One person or team in each src: |
team:Eng, team:eng_ops |
A team’s name is lower-case letters, digits and hyphens |
dst:team:eng |
A person or a team is never a destination |
dst:user:ann@acme.example |
A person is never a destination |
tag:web |
Tags are gone; use labels |
Related
Section titled “Related”- Run your own controller: the settings of a self-hosted controller
- Console API: the rules API
- CLI reference:
zqx test-access
For ZQX v0.25.1. Each page describes this release.