Documentation
¶
Index ¶
- Constants
- Variables
- func AwaitHealthy(ctx context.Context, svc blobcache.Service) error
- func DefaultActionsFile() (ret string)
- func DefaultGrantsFile() (ret string)
- func DefaultIdentitiesFile() (ret string)
- func DefaultObjectsFile() (ret string)
- func LoadPrivateKey(p string) (inet256.PrivateKey, error)
- func SavePrivateKey(p string, privKey inet256.PrivateKey) error
- func WriteActionsFile(w io.Writer, actions []Membership[Action]) error
- func WriteGrantsFile(w io.Writer, grants []Grant) error
- func WriteGroupsFile[T any](w io.Writer, membership []Membership[T], format func(T) string) error
- func WriteIdentitiesFile(w io.Writer, membership []Membership[Identity]) error
- func WriteObjectsFile(w io.Writer, objects []Membership[ObjectSet]) error
- type Action
- type Daemon
- type Grant
- type GroupName
- type Identity
- type Member
- type Membership
- func LoadActionsFile(p string) ([]Membership[Action], error)
- func LoadIdentitiesFile(p string) ([]Membership[Identity], error)
- func LoadObjectsFile(p string) ([]Membership[ObjectSet], error)
- func ParseActionsFile(r io.Reader) (ret []Membership[Action], _ error)
- func ParseGroupsFile[T any](r io.Reader, parse func([]byte) (T, error)) (ret []Membership[T], _ error)
- func ParseIdentitiesFile(r io.Reader) (ret []Membership[Identity], _ error)
- func ParseObjectsFile(r io.Reader) (ret []Membership[ObjectSet], _ error)
- type ObjectSet
- type Policy
- func (p *Policy) AllActionGroups() iter.Seq[string]
- func (p *Policy) AllGrants() iter.Seq[Grant]
- func (p *Policy) AllIdentityGroups() iter.Seq[string]
- func (p *Policy) AllObjectGroups() iter.Seq[string]
- func (p *Policy) CanConnect(peer blobcache.PeerID) bool
- func (p *Policy) CanCreate(peer blobcache.PeerID) bool
- func (p *Policy) IdentityMembersOf(group string) iter.Seq[Identity]
- func (p *Policy) IsIdentityDefined(iden Identity) bool
- func (p *Policy) Open(peer blobcache.PeerID, target blobcache.OID) blobcache.ActionSet
Constants ¶
const ( IdentitiesFilename = "IDENTITIES" ActionsFilename = "ACTIONS" ObjectsFilename = "OBJECTS" GrantsFilename = "GRANTS" )
Variables ¶
var Everyone = inet256.Everyone()
Functions ¶
func DefaultActionsFile ¶
func DefaultActionsFile() (ret string)
func DefaultGrantsFile ¶
func DefaultGrantsFile() (ret string)
func DefaultIdentitiesFile ¶
func DefaultIdentitiesFile() (ret string)
func DefaultObjectsFile ¶
func DefaultObjectsFile() (ret string)
func LoadPrivateKey ¶
func LoadPrivateKey(p string) (inet256.PrivateKey, error)
func SavePrivateKey ¶
func SavePrivateKey(p string, privKey inet256.PrivateKey) error
func WriteActionsFile ¶
func WriteActionsFile(w io.Writer, actions []Membership[Action]) error
func WriteGroupsFile ¶
WriteGroupsFile writes the memberships to the writer, such that they can be parsed by ParseGroupsFile.
func WriteIdentitiesFile ¶
func WriteIdentitiesFile(w io.Writer, membership []Membership[Identity]) error
WriteIdentitiesFile writes the memberships to the writer, such that they can be parsed by ParseIdentitiesFile. It inserts an extra newline every time the group changes from the previous membership.
func WriteObjectsFile ¶
func WriteObjectsFile(w io.Writer, objects []Membership[ObjectSet]) error
Types ¶
type Action ¶
type Action string
const ( Action_LOAD Action = "LOAD" Action_SAVE Action = "SAVE" Action_POST Action = "POST" Action_GET Action = "GET" Action_EXISTS Action = "EXISTS" Action_DELETE Action = "DELETE" Action_COPY_FROM Action = "COPY_FROM" Action_COPY_TO Action = "COPY_TO" Action_LINK_FROM Action = "LINK_FROM" Action_LINK_TO Action = "LINK_TO" Action_AWAIT Action = "AWAIT" Action_CLONE Action = "CLONE" Action_CREATE Action = "CREATE" )
func ParseAction ¶
type Daemon ¶
type Daemon struct {
StateDir string
}
Daemon manages the state and configuration for running a Blobache node.
func RunTestDaemon ¶
RunTestDaemon launches a test daemon and returns it and the API address. This function will block until the daemon is healthy. The daemon will be stopped and cleaned up at the end of the test. The test will fail during cleanup if the daemon fails to stop, and The test will not complete until the daemon is successfully torn down.
func (*Daemon) EnsurePolicyFiles ¶
EnsurePolicyFiles ensures that the policy files exist. Creating default files if they don't exist.
func (*Daemon) EnsurePrivateKey ¶
func (d *Daemon) EnsurePrivateKey() (inet256.PrivateKey, error)
EnsurePrivateKey generates a private key if it doesn't exist, and returns it.
type Grant ¶
func LoadGrantsFile ¶
LoadGrantsFile loads the grants file from the filesystem. p should be the path to the grants file.
type Identity ¶
func ParseIdentity ¶
type Member ¶
type Member[T any] struct { // Unit references a single element Unit *T // GroupRef references another group by name. GroupRef *GroupName // Empty is used to create empty groups. Empty *struct{} }
Member is a member of a group. Members can either refer to another group by name, or to a single element of type T.
func ParseMember ¶
type Membership ¶
Membership says that a group contains a member.
func LoadActionsFile ¶
func LoadActionsFile(p string) ([]Membership[Action], error)
LoadActionsFile loads the actions file from the filesystem. p should be the path to the actions file.
func LoadIdentitiesFile ¶
func LoadIdentitiesFile(p string) ([]Membership[Identity], error)
LoadIdentitiesFile loads the identities file from the filesystem. p should be the path to the identities file.
func LoadObjectsFile ¶
func LoadObjectsFile(p string) ([]Membership[ObjectSet], error)
LoadObjectsFile loads the objects file from the filesystem. p should be the path to the objects file.
func ParseActionsFile ¶
func ParseActionsFile(r io.Reader) (ret []Membership[Action], _ error)
func ParseGroupsFile ¶
func ParseIdentitiesFile ¶
func ParseIdentitiesFile(r io.Reader) (ret []Membership[Identity], _ error)
ParseIdentitiesFiles parses a Group file into a list of identity group memberships.
func ParseObjectsFile ¶
func ParseObjectsFile(r io.Reader) (ret []Membership[ObjectSet], _ error)
type ObjectSet ¶
type ObjectSet struct { // ByOID is a specific OID ByOID *blobcache.OID // All refers to all possible objects All *struct{} }
ObjectSet 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 ¶
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
func LoadPolicy ¶
LoadPolicy loads the 4 policy files from the filesystem. stateDir should be the path to the state directory.
func NewPolicy ¶
func NewPolicy(idens []Membership[Identity], actions []Membership[Action], objects []Membership[ObjectSet], grants []Grant) (*Policy, error)
func (*Policy) IdentityMembersOf ¶
func (*Policy) IsIdentityDefined ¶
IsDefined returns true if the identity is a defined group, or a peer.