Back to / accesscontroller

Package accesscontroller

Latest Go to latest

The highest tagged major version is .

Published: Oct 20, 2020 | License: Apache-2.0 | Module:


accesscontroller is a package handling permissions for OrbitDB stores


func CreateManifest

func CreateManifest(ctx context.Context, ipfs coreapi.CoreAPI, controllerType string, params ManifestParams) (cid.Cid, error)

CreateManifest Creates a new manifest and returns its CID

func WithLogger

func WithLogger(logger *zap.Logger) func(ac Interface)

type CreateAccessControllerOptions

type CreateAccessControllerOptions struct {
	SkipManifest bool
	Address      cid.Cid
	Type         string
	Name         string
	Access       map[string][]string
	// contains filtered or unexported fields

CreateAccessControllerOptions Options used to create an Access Controller

func (*CreateAccessControllerOptions) GetAccess

func (m *CreateAccessControllerOptions) GetAccess(role string) []string

func (*CreateAccessControllerOptions) GetAddress

func (m *CreateAccessControllerOptions) GetAddress() cid.Cid

func (*CreateAccessControllerOptions) GetAllAccess

func (m *CreateAccessControllerOptions) GetAllAccess() map[string][]string

func (*CreateAccessControllerOptions) GetName

func (m *CreateAccessControllerOptions) GetName() string

func (*CreateAccessControllerOptions) GetSkipManifest

func (m *CreateAccessControllerOptions) GetSkipManifest() bool

func (*CreateAccessControllerOptions) GetType

func (m *CreateAccessControllerOptions) GetType() string

func (*CreateAccessControllerOptions) SetAccess

func (m *CreateAccessControllerOptions) SetAccess(role string, allowed []string)

func (*CreateAccessControllerOptions) SetAddress

func (m *CreateAccessControllerOptions) SetAddress(c cid.Cid)

func (*CreateAccessControllerOptions) SetName

func (m *CreateAccessControllerOptions) SetName(name string)

func (*CreateAccessControllerOptions) SetType

func (m *CreateAccessControllerOptions) SetType(t string)

type Interface

type Interface interface {

	// Type Returns the type of the store as a string
	Type() string

	// GetAuthorizedByRole Returns the list of keys authorized for a given role
	GetAuthorizedByRole(role string) ([]string, error)

	// Grant Allows a new key for a given role
	Grant(ctx context.Context, capability string, keyID string) error

	// Revoke Removes the permission of a key to perform an action
	Revoke(ctx context.Context, capability string, keyID string) error

	// Load Fetches the configuration of the access controller using the given
	// address
	Load(ctx context.Context, address string) error

	// Save Persists the store configuration (its manifest)
	Save(ctx context.Context) (ManifestParams, error)

	// Close Closes the store
	Close() error

	SetLogger(logger *zap.Logger)
	Logger() *zap.Logger

Interface The interface for OrbitDB Access Controllers

type LogEntry

type LogEntry = iface.IPFSLogEntry

type Manifest

type Manifest struct {
	Type   string
	Params *CreateAccessControllerOptions

Manifest An access controller manifest

func ResolveManifest

func ResolveManifest(ctx context.Context, ipfs coreapi.CoreAPI, manifestAddress string, params ManifestParams) (*Manifest, error)

ResolveManifest Retrieves a manifest from its address

type ManifestParams

type ManifestParams interface {
	GetSkipManifest() bool
	GetAddress() cid.Cid
	GetType() string

	GetName() string
	SetAccess(string, []string)
	GetAccess(string) []string
	GetAllAccess() map[string][]string

ManifestParams List of getters for a manifest parameters

func NewEmptyManifestParams

func NewEmptyManifestParams() ManifestParams

func NewManifestParams

func NewManifestParams(address cid.Cid, skipManifest bool, manifestType string) ManifestParams

Create a new manifest parameters instance

func NewSimpleManifestParams

func NewSimpleManifestParams(manifestType string, access map[string][]string) ManifestParams

type Option

type Option func(ac Interface)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier