Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Access

Nobody writes access rules by hand. Who may open, read and move what follows from the pages themselves: a page for the board is the board’s, a desk’s buttons are its group’s. Portal compiles the content into one Cedar policy on every load, and every request asks that policy. The sign-in provider says who someone is; portal only decides what they may do.

Where the groups come from

The policy names groups; it does not hold them. A User entity’s parents are the person’s groups, and those come from the sign-in: the groups claim the provider sent, joined with the person’s active memberships when portal keeps them itself. Cedar sees one list either way.

What content compiles to

contentrule
a page with no qualifiesanyone may open and submit
qualifies: case_officersthat group may open and submit
requires_chain: /startthe visitor’s verified answer lineage must reach it
a resource with public: trueanyone may read it
a resource with requires_group: gthat group may read it
a desk resource’s transitionsthat group may make those moves
a list’s edit:that group, the list’s own by default, may change the bucket’s records through the form it names: edit on the bucket (edit:<bucket>:<group>). Reading the history is the same rule
an alternative’s self_transitionthe submitter may make it, from each state in from, with their link and their matching email
an alternative’s invite: {group}the page’s own group may invite into that group
an alternative’s invite: with no groupthe page’s own group may invite without a group: invite on accounts, a rule of its own (invite-account:<group>) that opens no group, and that no invite into a group grants
a form recording into a places buckettake on the board’s bucket, for whoever may submit it
a desk that moves a notice into sends_in (or the form, when it sends on arrival)notify on each audience: the group, or the bucket
a notice that is not mandatoryunsubscribe, for a Recipient whose token is the one kept for them
board.plan: public or : <group>feed on the board’s calendar
a places bucketfeed on it, for a Submitter holding one of its places and its address
qualifies / requires_group: committees_{key}_member on a [key] pagethat group of the record the page’s key names: its Record’s tag member (see A record’s groups)
an invite.group with a gap, or a record’s group’s managesinvite into that group, of the inviter’s record (any record, for a page’s fixed group)
each group of a bucket’s groups:read and post on its room, for that group of that record
any group the content names (see Rooms)read and post on that group’s own Room

Mutations always need a group, whatever public says. A schedule opening a record, and portal’s own moves on boards and notices, are made by portal, as a clock’s are, and grant no person anything. A resource with neither public nor requires_group is unreachable rather than open: the policy fails closed.

Reading the policy

iris check --path questions --access

prints every rule the content compiled to, as a table of who may do what from where to where. It is the fastest way to find a rule a content repo did not mean to write — a refusal available on the day a case arrives, a board that can decide a case it never received.

Asking it

Every decision carries the rule ids that granted it. Refusals and every mutation are written to the site’s log (target portal::access).

A program beside the site asks the same question over dhd/1 (May), with the same principal, action, resource and context the server uses internally — so an automation acting as a group gets exactly the answer a person in that group would.

A principal may also name a person by sub, phone or email and list no groups; portal then looks their memberships up before deciding. That is what makes the policy usable for someone who has never opened the site.

A record’s groups

A bucket with groups: (state machines) gives each record groups of its own, named <bucket>_<key>_<name>. The policy has a Record entity per such record, bucket its attribute and one tag per group, that group’s Group. Pages, lists, buckets, groups and rooms may be about one (record?), and a rule on committees_{key}_member asks resource has record && resource.record.bucket == "committees" && principal in resource.record.getTag("member"). What a resource is about is read when the decision is asked:

  • a page or a list: the key of its address (/committee/traffic);
  • a record (Resource::Record, for a move): its own key in a bucket with groups, else its belongs_to field;
  • a group or a room: its name, when it is one of a record’s (committees_traffic_member, with name: member).

A resource about no record meets no such rule, and a person’s groups with a gap in them are dropped before anything is asked.

A record that is its sender’s own

A bucket with owned_by: sender (state machines) has two rules, and so has every bucket that belongs to it:

@id("own:courses")
permit(principal is User, action in [Action::"see", Action::"talk"], resource == Bucket::"courses") when { principal.sub == context.owner };

@id("shared:courses:guides")
permit(principal in Group::"guides", action in [Action::"see", Action::"talk"], resource == Bucket::"courses") when { ["open"].contains(context.state) };

see is reading a record and talk its conversation. The context is read off the record when the question is asked: owner, the subject the site wrote on it, and state, where it stands; for a record that belongs to an owned one, both are that one’s. They are asked for every record of a list, for a desk’s move, for a change, for a file on the record and for a new record that would belong to it, beside the checks those had before, never instead of them. Nobody signed in, and a record with no owner, meet neither rule. iris check --access lists them (the owner | see, talk | bucket courses).

Rooms

Every group the content names has a room in the site’s chat (Rooms), and the policy says who is in it: a group may read and post its own room, the Room whose name is the group’s, and nothing else grants a room. One rule per group, with the id room:<group>:

@id("room:counter")
permit(principal in Group::"counter", action in [Action::"read", Action::"post"], resource == Room::"counter");

A group is named wherever the content names one: a page’s qualifies, a resource’s requires_group, an invite:’s group, a state’s grants:, a schedule’s handled_by and for_each.group, a notice’s senders and group audiences, a board’s plan: group, a responsible:’s group. iris check --access lists the rules with the rest (group counter | read, post | room counter); the map and the manual leave them out, since every group has one.

The chat asks with May over dhd/1, on every connection to a room and every post:

{ "principal": { "kind": "user", "sub": "<oidc sub>", "email": "a@b", "groups": ["counter"] },
  "action": "post",
  "resource": { "kind": "room", "name": "counter" } }

and gets the same answer as any other question: allow, and the rule that granted it (room:counter), or a refusal with none. A thread on a case is a question of its own, { "kind": "thread", "room": "counter", "bucket": "hires", "id": "7f3a…" }: of a record that is its sender’s own it is who may talk about that record, the owner and the group it is shared with while it is; of any other record it is answered as its room. A post is noted in the site’s log either way, a read only when refused, as for everything else.

The submitter

A person who sent a form has no account. Their credential is the link: an unguessable chain hash, plus the email they gave, which the policy compares against the one stored on the record.

What they may do, and from where, is self_transition.from. Its default is the initial state alone. A refusal reads “not found” while the record is somewhere the move could have been made from — so the endpoint cannot be used to discover which records or addresses exist — and “already processed” once the case has moved past it.