Documentation
¶
Overview ¶
Package capability implements narrow, expiring, optionally signed authorization tokens. Delegation may only reduce scope. Deny by default.
Index ¶
- Variables
- type Authority
- func (a *Authority) AdvanceEpoch() (antireplay.SecurityEpoch, error)
- func (a *Authority) Delegate(parent Token, req Request) (Token, error)
- func (a *Authority) Epoch() antireplay.SecurityEpoch
- func (a *Authority) Issue(req Request) (Token, error)
- func (a *Authority) Revoke(id ID) error
- func (a *Authority) Verify(tok Token) error
- type Constraints
- type ID
- type Option
- type Permission
- type Request
- type Token
Constants ¶
This section is empty.
Variables ¶
var ( ErrDenied = errors.New("capability: denied") ErrExpired = errors.New("capability: expired") ErrRevoked = errors.New("capability: revoked") ErrEpochMismatch = errors.New("capability: security epoch mismatch") ErrInvalidSig = errors.New("capability: invalid signature") ErrWidenDelegate = errors.New("capability: delegation cannot widen scope") ErrSingleUseSpent = errors.New("capability: single-use already spent") ErrNotFound = errors.New("capability: not found") )
Functions ¶
This section is empty.
Types ¶
type Authority ¶
type Authority struct {
// contains filtered or unexported fields
}
Authority issues and verifies capabilities.
func (*Authority) AdvanceEpoch ¶
func (a *Authority) AdvanceEpoch() (antireplay.SecurityEpoch, error)
AdvanceEpoch invalidates prior capabilities by epoch mismatch.
func (*Authority) Epoch ¶
func (a *Authority) Epoch() antireplay.SecurityEpoch
Epoch returns the current security epoch.
type Constraints ¶
type Constraints struct {
SingleUse bool `json:"single_use,omitempty"`
Environment string `json:"environment,omitempty"`
MaxUses int `json:"max_uses,omitempty"`
AllowedResources []string `json:"allowed_resources,omitempty"`
}
Constraints narrow how a capability may be used.
type Option ¶
type Option func(*Authority)
Option configures Authority.
func WithKeyRing ¶
WithKeyRing sets verification keys.
func WithReplayCache ¶
func WithReplayCache(c *antireplay.Cache) Option
WithReplayCache binds nonce checks to an anti-replay cache.
func WithSigner ¶
func WithSigner(key signing.PrivateKey, ring *signing.KeyRing) Option
WithSigner enables Ed25519 signing of issued tokens.
type Permission ¶
type Permission string
Permission is a stable permission string (e.g. claim.revoke).
type Request ¶
type Request struct {
Subject string
Permission Permission
Resource string
TTL time.Duration
Constraints Constraints
}
Request describes a capability to issue.
type Token ¶
type Token struct {
ID ID `json:"id"`
Subject string `json:"subject"`
Permission Permission `json:"permission"`
Resource string `json:"resource,omitempty"`
IssuedAt time.Time `json:"issued_at"`
ExpiresAt time.Time `json:"expires_at"`
Constraints Constraints `json:"constraints"`
Nonce string `json:"nonce"`
Epoch antireplay.SecurityEpoch `json:"epoch"`
ParentID ID `json:"parent_id,omitempty"`
Signature []byte `json:"signature,omitempty"`
KeyID string `json:"key_id,omitempty"`
}
Token is a capability grant. Contents must not include secrets.