Skip to main content

Module subject

Module subject 

Source
Expand description

The subjects a policy judges, and the diff a write carries to one.

didbot-pds’s write and OAuth paths build every subject here, and didbot-policy-check builds the same ones in a browser, so a page judges a hypothetical request the way the server judges a real one. Nothing here reads a clock: the instant is the caller’s, so the two agree on what “now” was.

§The diff carries values, not just paths

A rule that means to test a value cannot, from a path alone, tell a legitimate edit from a delete that removed the same path. Change carries both sides’ values instead, with absence itself represented as a value (None), so an evaluator can test what changed to what rather than merely that something at this path changed. diff computes it completely: every path whose value differs between before and after, including every path in a wholly new record (a create, before: None throughout) and every path in a wholly removed one (a delete, after: None throughout). There is no “empty diff for a delete” case, and a gate is entitled to rely on that.

Nothing here is a payload log. Change borrows from the two Values a write already holds in memory for the length of one judgment, and nothing stores, logs, or returns a Change past that call.

Structs§

OwnedChange
One field path whose value differs between before and after a write, as this crate computes and holds it.

Functions§

blob_subject
Builds the Subject::Blob a gate judges one upload against.
borrow
Borrows a whole diff at once. See OwnedChange::as_change.
create_subject
Builds the Subject::Create a gate judges for one pool and zone a create could land in. attributes is the creating account’s, when this server hosts it; name and label are set when the create gave a name.
diff
Computes the complete diff between before and after.
diff_into 🔒
grant_subject
Builds the Subject::Grant a gate judges one pushed authorization request against, before any account is known.
join 🔒
token_subject
Builds the Subject::Token a gate judges before a token is issued to client_id for account: an authorization code exchanged, or a refresh token rotated. scopes are the wire strings the token would carry.
universal 🔒
A deployment’s facts and the instant, as every subject carries them.
write_subject
Builds the Subject::Write a gate judges one write against.