Skip to content

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).

  • 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.
allow|deny src:<who> dst:<what> port:<n> proto:tcp|udp|icmp

any 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:managed is an Owner or Admin, on a node with the label os: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.

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:any

A 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:prod is every node with that label.
  • team is a rule word, so it is not a label namespace.
  • A controller without the SaaS gets teams only with the management scope login or full, 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-8099 is saved as 8000-8200.
  • A range goes from low to high. 8099-8000 is 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:admin includes Owners. An Owner can do what an Admin can.
  • autogroup:self is a destination only. It compares the destination’s person with the caller’s person. In src: 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 login or full (ZQX_SAAS_MANAGEMENT; refer to Run your own controller). With the scope read or off, autogroup:admin and autogroup:owner match nobody.

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

For ZQX v0.25.1. Each page describes this release.