Documentation
¶
Overview ¶
Package authz carries the record of one authorization decision: what a service decided about one subject, over which state, and its signature.
The decision itself is the application's. borg's contract defines what a role and a binding mean and folds them into a subject's effective permissions; a service establishes the subject's membership, fetches the records and evaluates them. This package writes down what came of that, so that a decision can be checked afterwards by someone who was not there: the receipt names the organization token the decision rested on, the grants and policy records it used, and the answer, and it is signed by the service that gave the answer.
A receipt is evidence, never authority. Holding one grants nothing: it says only that a service decided something at a time, against a state anyone can fetch and check for themselves.
Index ¶
Constants ¶
const ( // ProtocolName is the BRC-43 protocol name of a decision signature, at // security level 1: the signature is one anyone verifies from the // signer's published identity key. ProtocolName = "authz decision" // KeyID is the key id that protocol derives under. KeyID = "receipt" )
Registry values, frozen once a receipt is published.
const ( RKMagic = 0 RKBy = 1 RKOrg = 2 RKHall = 3 RKSubject = 4 RKPermission = 5 RKAllow = 6 RKSeq = 7 RKToken = 8 RKGrants = 9 RKPolicies = 10 RKTime = 11 RKReason = 12 )
Receipt keys.
const ( // MaxReceipt bounds an encoded receipt. MaxReceipt = 4096 // MaxUsed bounds the commitments one receipt lists per kind. MaxUsed = 64 // MaxPermission bounds the asked permission, borg's bound. MaxPermission = 256 // MaxHall bounds the rendezvous name a receipt carries. MaxHall = 64 // MaxReason bounds the label a denial carries. MaxReason = 64 // MaxTime is the last second RFC 3339 can write. MaxTime = 253402300799 )
Bounds.
Variables ¶
var ( ErrTooLarge = record.ErrTooLarge ErrCBOR = record.ErrCBOR ErrKeyType = record.ErrKeyType ErrMagic = record.ErrMagic ErrMissing = record.ErrMissing ErrType = record.ErrType ErrRange = record.ErrRange ErrList = record.ErrList ErrIdentity = errors.New("authz: key is not a canonical compressed key") ErrSignature = errors.New("authz: signature does not verify under the signer's key") )
The refusals.
var Derivation = pushdrop.Derivation{ Protocol: wallet.Protocol{SecurityLevel: wallet.SecurityLevelEveryApp, Protocol: ProtocolName}, KeyID: KeyID, }
Derivation is the derivation a receipt's signature is made and checked under: counterparty anyone, so a verifier derives the key from the signer's identity key alone.
var MagicReceipt = []byte{'a', 'z', 'r', 0x01}
MagicReceipt is key 0 of a receipt: "az", 'r', version 1.
Functions ¶
This section is empty.
Types ¶
type Receipt ¶
type Receipt struct {
// By is the identity key of the service that decided.
By []byte // key 1
// Org is the organization whose state the decision rested on.
Org []byte // key 2
// Hall is that organization's rendezvous.
Hall string // key 3
// Subject is the key the decision was about.
Subject []byte // key 4
// Permission is what was asked, in full and with no wildcard.
Permission string // key 5
// Allow is the answer.
Allow bool // key 6
// Seq and Token name the organization token the decision rested on: the
// state a checker fetches to reach the same answer.
Seq uint64 // key 7
Token [32]byte // key 8, txid in hash byte order
// Grants and Policies are the commitments of the records the decision
// used, ascending.
Grants [][32]byte // key 9
Policies [][32]byte // key 10
// Time is when the service decided, Unix seconds on its own clock.
Time uint64 // key 11
// Reason is a short label for a denial, empty for an allow.
Reason string // key 12
// Extra holds integer keys above the last this version defines.
Extra cbor.Map
}
Receipt is one decision, as it is written down and signed.
type Signed ¶
type Signed struct {
// Record is the receipt exactly as it was signed.
Record []byte
// Signature is strict low-S DER over SHA-256 of Record.
Signature []byte
}
Signed is a receipt and the signature over it, the pair a service hands out and a checker reads.