auth

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: AGPL-3.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorised = errors.New("Unauthorised")
View Source
var Undef = Want{}

Functions

This section is empty.

Types

type AuthBlock

type AuthBlock interface {
	Want() Want
	Cid() cid.Cid
	Size() int
	GetAuthedData() []byte
	Loggable() map[string]interface{}
}

func NewBlock

func NewBlock(block blocks.Block, a string) AuthBlock

type AuthBlockImpl

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

func (AuthBlockImpl) Cid

func (a AuthBlockImpl) Cid() cid.Cid

func (AuthBlockImpl) GetAuthedData

func (a AuthBlockImpl) GetAuthedData() []byte

func (AuthBlockImpl) Loggable

func (a AuthBlockImpl) Loggable() map[string]interface{}

func (AuthBlockImpl) Size

func (a AuthBlockImpl) Size() int

func (AuthBlockImpl) Want

func (a AuthBlockImpl) Want() Want

type AuthBlockstore

type AuthBlockstore interface {
	DeleteBlock(cid.Cid) error
	Has(cid.Cid) (bool, error)
	Get(cid.Cid, peer.ID, string) (blocks.Block, error)
	BloomAdd(cid.Cid) error

	// GetSize returns the CIDs mapped BlockSize
	GetSize(cid.Cid) (int, error)

	// Put puts a given block to the underlying datastore
	Put(AuthBlock) error

	// PutMany puts a slice of blocks at the same time using batching
	// capabilities of the underlying datastore whenever possible.
	PutMany([]AuthBlock) error

	// AllKeysChan returns a channel from which
	// the CIDs in the Blockstore can be read. It should respect
	// the given context, closing the channel if it becomes Done.
	AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

	// HashOnRead specifies if every read block should be
	// rehashed to make sure it matches its CID.
	HashOnRead(enabled bool)
}

func NewAuthBlockstore

func NewAuthBlockstore(bstore blockstore.Blockstore, allow func(cid.Cid, []byte, peer.ID, string) bool) AuthBlockstore

type AuthedBlockstore

type AuthedBlockstore struct {
	AuthBlockstore
	// contains filtered or unexported fields
}

func (*AuthedBlockstore) AllKeysChan

func (bs *AuthedBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

func (*AuthedBlockstore) BloomAdd added in v0.6.3

func (bs *AuthedBlockstore) BloomAdd(c cid.Cid) error

func (*AuthedBlockstore) DeleteBlock

func (bs *AuthedBlockstore) DeleteBlock(c cid.Cid) error

func (*AuthedBlockstore) Get

func (bs *AuthedBlockstore) Get(c cid.Cid, remote peer.ID, auth string) (blocks.Block, error)

func (*AuthedBlockstore) GetSize

func (bs *AuthedBlockstore) GetSize(c cid.Cid) (int, error)

func (*AuthedBlockstore) Has

func (bs *AuthedBlockstore) Has(c cid.Cid) (bool, error)

func (*AuthedBlockstore) HashOnRead

func (bs *AuthedBlockstore) HashOnRead(enabled bool)

func (*AuthedBlockstore) Put

func (bs *AuthedBlockstore) Put(b AuthBlock) error

func (*AuthedBlockstore) PutMany

func (bs *AuthedBlockstore) PutMany(authblocks []AuthBlock) error

type Set

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

func NewSet

func NewSet() *Set

func (*Set) Add

func (s *Set) Add(w Want)

func (*Set) ForEach

func (s *Set) ForEach(f func(w Want) error) error

func (*Set) Has

func (s *Set) Has(w Want) bool

func (*Set) Keys

func (s *Set) Keys() []Want

func (*Set) Len

func (s *Set) Len() int

func (*Set) Remove

func (s *Set) Remove(w Want)

func (*Set) Visit

func (s *Set) Visit(w Want) bool

Visit adds a Want to the set only if it is not in it already.

type Want

type Want struct {
	Cid  cid.Cid
	Auth string
}

func NewWant

func NewWant(c cid.Cid, a string) Want

func (Want) Defined

func (w Want) Defined() bool

func (Want) Equals

func (w Want) Equals(b Want) bool

Jump to

Keyboard shortcuts

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