Documentation
¶
Overview ¶
Package identity is who the parties are: their keys and cards, how two parties come to trust each other, and how they sign and seal what they write.
Index ¶
- Constants
- Variables
- func CheckName(name string) error
- func Decode(data []byte, into any) error
- func Encode(v any) ([]byte, error)
- func Exists(path string) bool
- func Holds(prefixes []string, location string) bool
- func Kept(kind Kind) string
- func TrustOwn(ctx context.Context, s store.Store, ctl *Identity, runner, client Card, ...) error
- func WriteTrust(ctx context.Context, s store.Store, ctl *Identity, t Trust) error
- type Card
- type Config
- func (c Config) ControllerStore() (string, error)
- func (c Config) Has(kind Kind) bool
- func (c Config) IdentityAddress(kind Kind) (string, error)
- func (c Config) Keep(id *Identity) error
- func (c Config) Load(ctx context.Context, kind Kind) (*Identity, error)
- func (c Config) Make(ctx context.Context, kind Kind, name string) (*Identity, error)
- func (c Config) Party(ctx context.Context, kind Kind) (Party, error)
- func (c Config) SetControllerStore(address string) error
- func (c Config) SetIdentityAddress(kind Kind, address string) error
- func (c Config) SetStoreListen(at string) error
- func (c Config) SetTrust(kind Kind, t Trust) error
- func (c Config) SetUp(ctx context.Context, s store.Store, address, name, identityAddress string, ...) (ctl, runner, client *Identity, err error)
- func (c Config) StoreListen() (string, error)
- func (c Config) Trust(kind Kind, controller string) (*Trust, error)
- func (c Config) TrustList(kind Kind) ([]Trust, error)
- type Identity
- type Kind
- type Party
- type Trust
- type Value
Constants ¶
const ClockAllowance = 5 * time.Minute
ClockAllowance is how far two parties' clocks may differ. A receiver allows this much before it treats another party's time as passed.
Variables ¶
var ( // ErrAltered is a value whose signature does not hold, or that was // found under a name it was not signed for. ErrAltered = errors.New("the value has been altered or moved") // ErrNotForUs is a sealed value this identity cannot open. ErrNotForUs = errors.New("the value is not sealed to this identity") )
var ErrTrustsNone = errors.New("this computer's client trusts no controller yet: corbie init sets one computer up, and corbie client trust takes a controller's card")
ErrTrustsNone is the error of a config whose client trusts no controller.
Functions ¶
func CheckName ¶
CheckName says whether a party may have the name: it is one part of a store's names, of letters, digits, dots, dashes and underscores.
func Decode ¶
Decode reads JSON strictly: an unknown name, a repeated name or a name in the wrong case is an error.
func Encode ¶
Encode writes v as JSON in the one form signed and stored values have: the same value always gives the same bytes.
func Holds ¶ added in v0.26.0
Holds says whether one of the prefixes holds the location: whether it is the location or above it. No prefix is "/", which holds every location.
func Kept ¶ added in v0.24.0
Kept is the name an identity of the kind has in the bucket that keeps it.
func TrustOwn ¶ added in v0.50.0
func TrustOwn(ctx context.Context, s store.Store, ctl *Identity, runner, client Card, ceiling permission.Layer) error
TrustOwn writes the controller's trust of its own runner and client: the runner's with no ceiling, the client's with the ceiling and at:/**, so the client may submit a tree at any prefix. A name stays tied to the key it was first trusted with, and both are read and checked before either is written.
Types ¶
type Card ¶
A Card is the public side of an identity: a name, a kind and two public keys, signed by itself. Its text form is one line.
func (Card) Fingerprint ¶
Fingerprint is a short mark of the card, made from its name, its kind and both of its keys, for two people to compare.
func (Card) MarshalText ¶
func (*Card) UnmarshalText ¶
type Config ¶
type Config struct {
Dir string
}
A Config is the directory that holds a machine's parties: a place each for a controller, a runner and a client.
<config>/controller/identity the controller's keys <config>/controller/store the address of its store <config>/runner/identity the runner's keys <config>/runner/trust/<name> a controller the runner serves <config>/client/identity the client's keys <config>/client/trust/<name> the client's controller
In place of identity, a party's directory may hold identity-address: the address of the bucket that keeps its keys.
func DefaultConfig ¶
DefaultConfig is where a machine's parties live unless it is told otherwise.
func (Config) ControllerStore ¶
ControllerStore is the address of the controller's store.
func (Config) Has ¶
Has says whether the config holds an identity of the kind, or the address of one.
func (Config) IdentityAddress ¶ added in v0.24.0
IdentityAddress is the address of the bucket that keeps the identity of the kind, or nothing where the identity is a file in the config.
func (Config) Make ¶
Make gives the identity of the kind, making it with the name if there is none. A name once chosen is never changed: an identity that exists is given as it is.
func (Config) Party ¶ added in v0.50.0
Party gives the config's controller, or its client with the controller it trusts. A runner works with each controller it trusts, and is refused.
func (Config) SetControllerStore ¶
SetControllerStore notes the address of the controller's store.
func (Config) SetIdentityAddress ¶ added in v0.24.0
SetIdentityAddress notes the bucket that keeps the identity of the kind. An identity stays where it was made: a config that holds the file, or records another address, is refused.
func (Config) SetStoreListen ¶ added in v0.4.0
SetStoreListen notes where the store's server listens, or with nothing given that the directory is not served.
func (Config) SetUp ¶ added in v0.50.0
func (c Config) SetUp(ctx context.Context, s store.Store, address, name, identityAddress string, ceiling permission.Layer) (ctl, runner, client *Identity, err error)
SetUp makes a controller, a runner and a client in the config, named after name, each trusting the others, on the store at an address, and sets the store up. identityAddress, where given, is the address --identity gives, of the bucket that keeps the identities. The runner gives the controller the ceiling.
func (Config) StoreListen ¶ added in v0.4.0
StoreListen is where the store's server on the controller's computer listens, as host:port, or nothing where the directory is not served.
type Identity ¶
type Identity struct {
Card
// contains filtered or unexported fields
}
An Identity is a party's two private keys, with its card.
func Load ¶
Load reads an identity from its file. A file that anyone but its owner can read is refused. No error it gives holds anything from the file.
func (*Identity) Certificate ¶ added in v0.50.0
func (id *Identity) Certificate() (tls.Certificate, error)
Certificate is what the identity shows of itself to the other end of a served directory's wire: that it holds its signing key.
func (*Identity) Save ¶
Save writes the identity to a file only its owner can read, whole or not at all.
func (*Identity) Secret ¶ added in v0.50.0
Secret gives a secret that follows from the identity's signing key and from data: the same data gives the same secret, and no other identity can give it. It is an HMAC-SHA256 of the data, under a key that HKDF derives from the private key with a fixed label, so it follows from nothing the identity signs.
type Party ¶ added in v0.50.0
A Party is a party of a config as it opens a store: its identity, nil for a client with none, the controller it works with, and the address of that controller's store the config records.
type Trust ¶
type Trust struct {
Card Card `json:"card"`
Ceiling permission.Layer `json:"ceiling,omitzero"`
Tags []string `json:"tags,omitzero"`
Prefixes []string `json:"prefixes,omitzero"`
Store string `json:"store,omitzero"`
Removed bool `json:"removed,omitzero"`
}
Trust is what one party holds about another it has taken the card of: the card, and the limit trust was given with. A controller gives a client a ceiling and a runner its tags and prefixes; a runner gives a controller a ceiling and the same prefixes, and notes the address of that controller's store, as a client does. A runner is sent, and takes, only the jobs of runs at or under one of its prefixes; none is "/".
A removed party stays on record with its key, so its name stays tied to that key.
func ReadTrust ¶
ReadTrust reads what a controller holds about a party from its store. It is read afresh each time it is asked for.
func Take ¶
Take is what trusting a card gives, given what is on record under its name. A name stays tied to the key it was first taken with, also after the party was removed: a different key is refused unless replace says it takes the old one's place. The same key keeps its ceiling and tags on record, and what another key was given is not carried over; a runner's prefixes and the address of a controller's store are kept for either.
type Value ¶
type Value struct {
By string `json:"by"`
At string `json:"at"`
Sent time.Time `json:"sent"`
Until time.Time `json:"until,omitzero"`
Sealed bool `json:"sealed,omitzero"`
// contains filtered or unexported fields
}
A Value is something a party signed: three lines of text. The first is the frame, which says who signed it, which name in the store it belongs under, when it was written and when it stops being good. The second is the body, as JSON, or sealed so that only the parties it was sealed to can read it. The third is the signature over the first two.
The frame is bound into the sealing, so nobody can wrap a sealed body in a frame of their own.
func Parse ¶
Parse reads a value's frame. Nothing is checked: until Check has passed, the frame is whatever its writer chose.
func Read ¶
Read is Parse, Check and Open together, for a value whose signer is known before it is read.
func (Value) Check ¶
Check says whether the value was signed by the card and belongs under the name it was found at.