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 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) Load(kind Kind) (*Identity, error)
- func (c Config) Make(kind Kind, name string) (*Identity, error)
- func (c Config) Served() (string, error)
- func (c Config) SetControllerStore(address string) error
- func (c Config) SetServed(at string) error
- func (c Config) SetTrust(kind Kind, t Trust) error
- func (c Config) Trust(kind Kind, controller string) (*Trust, error)
- func (c Config) TrustList(kind Kind) ([]Trust, error)
- type Identity
- type Kind
- 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 party") )
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.
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
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) 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) Served ¶
Served is where the controller's computer serves its directory to other machines, as host:port, or nothing where it does not.
func (Config) SetControllerStore ¶
SetControllerStore notes the address of the controller's store.
func (Config) SetServed ¶
SetServed notes where the controller's computer serves its directory, or with nothing given that it does not.
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) Proof ¶
func (id *Identity) Proof() (tls.Certificate, error)
Proof 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.
type Trust ¶
type Trust struct {
Card Card `json:"card"`
Ceiling permission.Layer `json:"ceiling,omitzero"`
Tags []string `json:"tags,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; a runner gives a controller a ceiling, and notes the address of that controller's store, as a client does.
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. What the old key was given is not carried over.
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.