Policy file reference

Every field of the access policy document, including shadowing, exit-point and SSH rules: types, defaults, accepted values and the checks run when you save.

Updated · ·By Ivan Vyshniak

Nothing on this page changes with your selection.

The access policy is one JSON document per network. Edit it in Access → Advanced in the console, or with GET and PUT /v1/network/acl in the REST API. For how it is applied, see How access control works.

Top level

json
{
  "rules":     [ ],
  "groups":    { },
  "tests":     [ ],
  "shadowing": [ ],
  "exit_points": [ ],
  "ssh": [ ]
}
KeyTypePurpose
rulesarray of rulesTraffic rules, evaluated top to bottom.
groupsobject of groupsNamed lists of people.
testsarray of testsChecks that must pass for a save to succeed.
shadowingarray of shadowing rulesWho may view or control desktop sessions.
exit_pointsarray of exit-point entriesWho may use each approved exit point. One entry per exit point you add; an exit point without one allows nobody.
ssharray of SSH rulesWho may log in to which devices over Peerlify SSH, and as which account. No rule allows nobody.
  • The document must be strict JSON: no comments, no trailing commas.
  • Unknown keys are ignored without a warning. A section with the wrong type is also ignored, so a typo such as "rule": [...] or "rules": {} saves a policy with no rules, which denies all traffic.
  • A bare array at the top level is accepted as the list of rules. Saving it stores an empty groups, tests, shadowing and ssh, deleting any you had. Exit-point entries are kept.
  • The same goes for a document that leaves a section out: saving a document without ssh (or shadowing, groups, tests) deletes the rules that section held. Only exit_points is kept when its key is absent.
  • The ssh section is the exception to "the wrong type is ignored": anything but an array there refuses the document.
  • Peerlify stores a normalized copy of what you save: keys in a fixed order, two-space indentation, and allowed_sessions / consent_required spellings in shadowing rules.

Rule

json
{
  "name": "App servers reach the database",
  "description": "Postgres from the app tier",
  "action": "accept",
  "source": ["tag:app"],
  "destination": ["tag:db"],
  "ports": ["5432"],
  "protocol": ["tcp"],
  "enabled": true
}
FieldTypeDefaultAccepted values
namestring""Any text. Shown in logs as unnamed when empty.
descriptionstring""Any text.
actionstring"accept"accept or allow (in any case) admit the packet. Any other value denies it. When you save, Peerlify stores the action as accept or drop: allow becomes accept, and deny, other text and non-string values become drop.
sourcearray of strings[]Selectors. An empty list matches nothing.
destinationarray of strings[]Selectors. An empty list matches nothing.
portsarray of strings or integers[] (any port)"443", "8000-8999" (inclusive) or "*". Integers from 0 to 65535 are saved as strings (22 → "22"). Compared with the destination port of TCP, UDP and SCTP. Portless protocols only match "*".
protocolarray of strings or integers[] (any protocol)tcp, udp, icmp, a protocol number "1"–"255" (SCTP is "132"), or "*". Integers from 1 to 255 are saved as strings.
enabledbooleantruefalse keeps the rule but skips it.

A missing, null or empty ports or protocol list means every port or protocol. Any other entry that isn't a non-empty string or an in-range integer refuses the whole document, for example Rule 'ssh': ports[1] must be a string or an integer, got True. A rule without a name is called #1, #2 and so on, by position.

Write source and destination entries as strings

In source and destination, only string entries are kept; other values are dropped without an error. An empty list there matches nothing.

Selectors

Used in source and destination of rules, shadowing rules and SSH rules.

SelectorMatches
*Every device in the network.
tag:<name>Devices carrying the tag.
email:<address>Untagged devices with an active session for that person.
group:<name>Untagged devices of every person in the group.
role:<role>Untagged devices of every approved member with that role: owner, admin, it-admin, network-admin, billing-admin, auditor, member.
client:<deviceId>The device with that 9-digit device ID.
ip:<address>The device with that overlay IPv4 address. Exact match; CIDR ranges never match.
a value containing @Same as email:.
any other valueMatched against a device's overlay IP, device ID or tag name.

Matching is case-insensitive. See Tags, groups and roles.

Groups

json
"groups": {
  "group:sre": ["alice@example.com", "bob@example.com"],
  "group:platform": ["group:sre", "carol@example.com"]
}
  • Each key must start with group: and have a name after it.
  • Each value is an array of email addresses or other group: names.
  • Groups may nest. Every referenced group must exist, and cycles are rejected.
  • The number of groups is limited by plan.

Test

json
{
  "name": "web tier can't reach the database",
  "src": "tag:web",
  "proto": "tcp",
  "accept": [],
  "deny": ["tag:db:5432"]
}
FieldTypeDefaultMeaning
namestringnoneA label.
srcstring""The source to test, written as a selector. A group: value also counts as each of its members.
acceptarray of strings[]Destinations that must be allowed.
denyarray of strings[]Destinations that must be denied.
protostringnoneIf set, a rule counts only when its protocol list contains this value, *, or nothing.

Destinations are a selector, optionally followed by : and a port: tag:db:5432, ip:100.100.0.12:443. Without a port, any port matches. A port of * (tag:web:*) doesn't mean any port: it matches only rules whose ports include *.

Tests compare selectors as text. They don't know which devices carry a tag or who owns a device, so write tests with the same selectors your rules use. There are also differences from how devices evaluate rules:

  • A rule with an empty ports list does not match a test destination that names a port, although devices treat it as any port.
  • Protocols are compared as text, so "6" and "tcp" are different.
  • email:alice@example.com and alice@example.com are different values, and role: selectors are not expanded.

Shadowing rule

json
{
  "name": "Helpdesk views staff desktops",
  "description": "",
  "source": ["group:helpdesk"],
  "destination": ["tag:workstation"],
  "allowed_sessions": ["group:Remote-Desktop-Users"],
  "control": false,
  "consent_required": true,
  "enabled": true
}
FieldTypeDefaultMeaning
namestring""A label.
descriptionstring""Free text.
sourcearray of strings[]Who may shadow (selectors).
destinationarray of strings[]Which devices may be shadowed (selectors).
allowed_sessionsarray of strings[]*, group:<local group>, or an account name on the target. Empty matches nothing. Also accepted as allowedSessions.
controlbooleanfalsetrue allows keyboard and mouse control.
consent_requiredbooleanfalsetrue asks the person at the device first. Also accepted as consentRequired.
enabledbooleantruefalse keeps the rule but skips it.

See Shadowing rules.

Exit-point entry

json
{
  "exit_point": "client:482915307",
  "name": "office-gw",
  "source": ["group:staff", "tag:laptops"]
}
FieldTypeMeaning
exit_pointstringThe exit point, as client:<device ID>. Must be an approved exit point of the network.
namestringThe exit point's name in the network. A label only; Peerlify refreshes it when you save.
sourcearray of stringsWho may use the exit point: selectors, * for every device. Empty means nobody.

At most one entry per approved exit point. An approved exit point without an entry allows nobody:

  • Approving a device as an exit point doesn't write the document. You add the entry (the console's Add exit-point rule, or a save that includes it) and remove it by saving without it. Revoking approval, or removing the device, deletes the entry.
  • When the document you save has an exit_points key, it decides which entries exist: an entry for an approved exit point is kept, an entry you leave out is deleted, and an entry for a device that isn't an approved exit point is dropped. Only source is applied; name is refreshed.
  • A document without exit_points changes no entry.
  • The save response (console and REST API) lists droppedExitPoints, the device IDs of entries it didn't accept, and removedExitPoints, the device IDs of saved entries it took away (left out, or no longer an approved exit point).
  • A console save names the policy version it started from and is refused with 409 if the policy changed since (reload and apply the change again). An API save doesn't: the last write wins.
  • Two entries for the same exit point, or an exit_point that isn't client:<device ID>, refuse the save.
  • Tests don't check exit-point use, and rules don't grant or require it.

Devices a required exit point rule covers may use that exit point even when they aren't in source.

SSH rule

json
{
  "name": "Admins to servers",
  "description": "",
  "source": ["group:admins"],
  "destination": ["tag:servers"],
  "users": ["root", "deploy"],
  "enabled": true
}
FieldTypeDefaultMeaning
namestring""A label.
descriptionstring""Free text.
sourcearray of strings[]Which devices may connect (selectors). Empty matches nothing.
destinationarray of strings[]Which devices they may log in to: selectors, or autogroup:self. Empty matches nothing.
usersarray of stringsrequiredThe accounts on the destination they may log in as. At least one.
enabledbooleantruefalse keeps the rule but skips it.

autogroup:self in destination means a device owned by the same person as the connecting device: the login is allowed only when one person is signed in to Peerlify on both. A tagged device has no owner, so autogroup:self never matches it, as source or as destination. It can be combined with other destinations in one rule; the rule applies if any of them matches. It isn't accepted in source.

Each users entry is one of:

EntryMatches
an account nameThat account on the destination. 1 to 64 characters: a letter or _ first, then letters, digits, _, - or ., optionally ending with $.
autogroup:nonrootAny account except root.
*Any account, root included.

Account names are the destination's own accounts and are never looked up in Peerlify.

Unlike the other sections, an SSH rule is checked strictly, and anything wrong refuses the save, naming the rule and the entry:

  • ssh that isn't an array, or an entry in it that isn't an object;
  • source, destination or users that isn't an array, or holds a value that isn't a non-empty string;
  • name or description that isn't a string, or enabled that isn't true or false;
  • a missing or empty users;
  • a users entry that isn't an account name, autogroup:nonroot or *, for example SSH rule 'Admins to servers': users entry 'bob smith' may contain only letters, digits, '_', '-' and '.', optionally ending with '$'.;
  • any autogroup: value other than autogroup:nonroot in users and autogroup:self in destination.

Entries are trimmed and duplicates removed when you save. A rule without a name is called #1, #2 and so on, by position.

An SSH rule opens no port: the rules must also allow TCP port 22 to the destination. Tests don't check SSH rules. See SSH to a device without keys.

Checks when you save

A save from the console runs these checks in order and stops at the first failure:

CheckError
You have the Owner, Admin or Network admin roleYou don't have permission to edit access controls.
The document parsesInvalid JSON. or Top-level value must be an object or rule array.
ports and protocol entries are strings or in-range integersRule '<name>': ports[<i>] must be … (see Rule)
Group keys start with group:Group name must start with 'group:' — got '<key>'.
No shadowing rule has a network selector in allowed_sessionsShadowing rule '<name>': allowed_sessions atom '<atom>' is a network selector. …
SSH rules are well formedSSH rule '<name>': … (see SSH rule)
Groups resolveInvalid groups., with details such as Group '<g>' references unknown group '<m>'. or Group cycle detected: …
Exit-point entries name client:<device ID>, once eachExit-point rule #<n>: 'exit_point' must be 'client:<device id>', got '<value>'. or Exit-point rule #<n>: exit point 'client:<id>' appears more than once; each exit point has exactly one rule.
The plan's group limit<Plan> plan allows <N> ACL groups; this policy defines <count>. Upgrade for more.
You manage every tag the document newly refers toYou don't manage the tag: <tag>. …
Every test passes<n> ACL test(s) failed.

Not checked: the syntax of port and protocol strings (such as "22-" or "tcpp"), whether tags exist, whether rules refer to declared groups, and empty source or destination lists.

The last save wins. If two people edit at once, the later save replaces the earlier one.

Next steps

Was this page helpful?