accesscontroller

package
v1.23.4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

accesscontroller is a package handling permissions for OrbitDB stores

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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)

Types

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 (*CreateAccessControllerOptions) GetSkipManifest

func (m *CreateAccessControllerOptions) GetSkipManifest() bool

func (*CreateAccessControllerOptions) GetType

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 {
	accesscontroller.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
	SetAddress(cid.Cid)
	GetType() string
	SetType(string)

	GetName() string
	SetName(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)

Directories

Path Synopsis
ipfs is an access controller
ipfs is an access controller
orbitdb is an access controller for OrbitDB stores
orbitdb is an access controller for OrbitDB stores
simple is an access controller without any persistence
simple is an access controller without any persistence
utils is a package containing tools related to access controllers
utils is a package containing tools related to access controllers

Jump to

Keyboard shortcuts

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