blobcached

package
v0.0.0-...-1ef88f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthnFilename = "AUTHN"
	AuthzFilename = "AUTHZ"
)

Variables

This section is empty.

Functions

func AwaitHealthy

func AwaitHealthy(ctx context.Context, svc blobcache.Service) error

func LoadPrivateKey

func LoadPrivateKey(p string) (inet256.PrivateKey, error)

func Run

func Run(ctx context.Context, stateDir string, pc net.PacketConn, serveAPI net.Listener) error

Run runs the blobcache daemon, until the context is cancelled. If the context is cancelled, Run returns nil. Run returns an error if it returns for any other reason.

func SavePolicy

func SavePolicy(stateDir string, policy *Policy) error

func SavePrivateKey

func SavePrivateKey(p string, privKey inet256.PrivateKey) error

func WriteAuthnFile

func WriteAuthnFile(w io.Writer, membership []Membership) error

WriteAuthnFile writes the memberships to the writer, such that they can be parsed by ParseAuthnFile. It inserts an extra newline every time the group changes from the previous membership.

func WriteAuthzFile

func WriteAuthzFile(w io.Writer, grants []Grant) error

Types

type Action

type Action string
const (
	Action_LOOK  Action = "LOOK"
	Action_TOUCH Action = "TOUCH"
	Action_OWN   Action = "OWN"
)

func ParseAction

func ParseAction(x []byte) (Action, error)

type Daemon

type Daemon struct {
	StateDir string
}

func (*Daemon) EnsurePrivateKey

func (d *Daemon) EnsurePrivateKey() (inet256.PrivateKey, error)

EnsurePrivateKey generates a private key if it doesn't exist, and returns it.

func (*Daemon) GetDB

func (d *Daemon) GetDB() (*sqlx.DB, error)

GetDB opens the database file, runs any migrations, and returns the database.

func (*Daemon) GetPolicy

func (d *Daemon) GetPolicy() (*Policy, error)

type Grant

type Grant struct {
	Subject Identity
	Verb    Action
	Object  Object
}

func LoadAuthzFile

func LoadAuthzFile(p string) ([]Grant, error)

LoadAuthzFile loads the authz file from the filesystem.

func ParseAuthzFile

func ParseAuthzFile(r io.Reader) (ret []Grant, _ error)

func (*Grant) Equals

func (g *Grant) Equals(other Grant) bool

type Identity

type Identity struct {
	// Name references a group.
	Name *string
	// Peer is a single peer.
	Peer *blobcache.PeerID
}

func ParseIdentity

func ParseIdentity(x []byte) (Identity, error)

func (Identity) Equals

func (iden Identity) Equals(other Identity) bool

func (Identity) String

func (iden Identity) String() string

type Membership

type Membership struct {
	Group  string
	Member Identity
}

func LoadAuthnFile

func LoadAuthnFile(p string) ([]Membership, error)

LoadAuthnFile loads the authn file from the filesystem.

func ParseAuthnFile

func ParseAuthnFile(r io.Reader) (ret []Membership, _ error)

type Object

type Object struct {
	ByOID   *blobcache.OID
	NameSet *regexp.Regexp
}

Object is something that Actions are performed on. It can be a specific OID, or a set of names defined by a regular expression.

func ParseObject

func ParseObject(x []byte) (Object, error)

func (Object) Equals

func (o Object) Equals(other Object) bool

func (Object) String

func (o Object) String() string

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

func LoadPolicy

func LoadPolicy(stateDir string) (*Policy, error)

LoadPolicy loads the 2 policy files ( {stateDir}/AUTHN and {stateDir}/AUTHZ ) from the filesystem.

func NewPolicy

func NewPolicy(membership []Membership, grants []Grant) *Policy

func (*Policy) AddGrant

func (p *Policy) AddGrant(grant Grant) bool

func (*Policy) AddMember

func (p *Policy) AddMember(group string, member Identity) bool

func (*Policy) AllGrants

func (p *Policy) AllGrants() iter.Seq[Grant]

func (*Policy) AllGroups

func (p *Policy) AllGroups() iter.Seq[string]

func (*Policy) AllMemberships

func (p *Policy) AllMemberships() iter.Seq[Membership]

AllMemberships returns all the memberships in topological order. The order is such that a group can only be mentioned after all the groups it depends on have been mentioned.

func (*Policy) CanLook

func (p *Policy) CanLook(subject blobcache.PeerID, oid blobcache.OID) bool

func (*Policy) IsIdentityDefined

func (p *Policy) IsIdentityDefined(iden Identity) bool

IsDefined returns true if the identity is a defined group, or a peer.

func (*Policy) MembersOf

func (p *Policy) MembersOf(group string) iter.Seq[Identity]

func (*Policy) RemoveGrant

func (p *Policy) RemoveGrant(grant Grant) bool

func (*Policy) RemoveMember

func (p *Policy) RemoveMember(group string, member Identity) (didChange bool)

func (*Policy) Supersets

func (p *Policy) Supersets(a, b Identity) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL