Documentation
¶
Index ¶
- Constants
- Variables
- func WrapAclRecord(rawRec *consensusproto.RawRecord) *consensusproto.RawRecordWithId
- type AccountAdd
- type AccountRemovePayload
- type AccountState
- type AccountsAddPayload
- type AclAccountState
- type AclKeys
- type AclList
- type AclPermissions
- type AclRecord
- type AclRecordBuilder
- type AclState
- func (st *AclState) AccountKey() crypto.PrivKey
- func (st *AclState) ApplyRecord(record *AclRecord) (err error)
- func (st *AclState) Copy() *AclState
- func (st *AclState) CurrentAccounts() []AccountState
- func (st *AclState) CurrentMetadataKey() (crypto.PubKey, error)
- func (st *AclState) CurrentReadKey() (crypto.SymKey, error)
- func (st *AclState) CurrentReadKeyId() string
- func (st *AclState) DecryptInvite(invitePk crypto.PrivKey) (key crypto.SymKey, err error)
- func (st *AclState) FirstMetadataKey() (crypto.PrivKey, error)
- func (st *AclState) GetInviteIdByPrivKey(inviteKey crypto.PrivKey) (recId string, err error)
- func (st *AclState) GetMetadata(identity crypto.PubKey, decrypt bool) (res []byte, err error)
- func (st *AclState) HadReadPermissions(identity crypto.PubKey) (had bool)
- func (st *AclState) Identity() crypto.PubKey
- func (st *AclState) InviteIds() []string
- func (st *AclState) Invites(inviteType ...aclrecordproto.AclInviteType) []Invite
- func (st *AclState) IsEmpty() bool
- func (st *AclState) JoinRecord(identity crypto.PubKey, decrypt bool) (RequestRecord, error)
- func (st *AclState) JoinRecords(decrypt bool) (records []RequestRecord, err error)
- func (st *AclState) Key() crypto.PrivKey
- func (st *AclState) Keys() map[string]AclKeys
- func (st *AclState) LastRecordId() string
- func (st *AclState) OwnerPubKey() (ownerIdentity crypto.PubKey, err error)
- func (st *AclState) Permissions(identity crypto.PubKey) AclPermissions
- func (st *AclState) PermissionsAtRecord(id string, pubKey crypto.PubKey) (AclPermissions, error)
- func (st *AclState) ReadKeyForAclId(id string) (string, error)
- func (st *AclState) Record(identity crypto.PubKey) (RequestRecord, error)
- func (st *AclState) RemoveRecords() (records []RequestRecord)
- func (st *AclState) RequestIds() []string
- func (st *AclState) Validator() ContentValidator
- type AclStatus
- type AclTestExecutor
- type BatchRequestPayload
- type BatchResult
- type ContentValidator
- type Invite
- type InviteChangePayload
- type InviteJoinPayload
- type InviteResult
- type IterFunc
- type NewInvites
- type PermissionChange
- type PermissionChangePayload
- type PermissionChangesPayload
- type RWLocker
- type ReadKeyChangePayload
- type RequestAcceptPayload
- type RequestJoinPayload
- type RequestRecord
- type RequestType
- type RootContent
- type Storage
- func CreateStorage(ctx context.Context, root *consensusproto.RawRecordWithId, ...) (Storage, error)
- func CreateStorageTx(ctx context.Context, root *consensusproto.RawRecordWithId, ...) (Storage, error)
- func NewInMemoryStorage(id string, records []*consensusproto.RawRecordWithId) (Storage, error)
- func NewStorage(ctx context.Context, id string, headStorage headstorage.HeadStorage, ...) (Storage, error)
- type StorageIterator
- type StorageProvider
- type StorageRecord
- type TestAclState
- type UserPermissionPair
Constants ¶
View Source
const ( AclPermissionsNone = AclPermissions(aclrecordproto.AclUserPermissions_None) AclPermissionsReader = AclPermissions(aclrecordproto.AclUserPermissions_Reader) AclPermissionsGuest = AclPermissions(aclrecordproto.AclUserPermissions_Guest) // like reader, but can't request removal and can't be upgraded to another permission AclPermissionsWriter = AclPermissions(aclrecordproto.AclUserPermissions_Writer) AclPermissionsAdmin = AclPermissions(aclrecordproto.AclUserPermissions_Admin) AclPermissionsOwner = AclPermissions(aclrecordproto.AclUserPermissions_Owner) )
View Source
const MaxMetadataLen = 1024
Variables ¶
View Source
var ( ErrNoSuchAccount = errors.New("no such account") ErrPendingRequest = errors.New("already exists pending request") ErrUnexpectedContentType = errors.New("unexpected content type") ErrIncorrectIdentity = errors.New("incorrect identity") ErrIncorrectInviteKey = errors.New("incorrect invite key") ErrFailedToDecrypt = errors.New("failed to decrypt key") ErrNoMetadataKey = errors.New("no metadata key") ErrNoSuchRecord = errors.New("no such record") ErrNoSuchRequest = errors.New("no such request") ErrNoSuchInvite = errors.New("no such invite") ErrInsufficientPermissions = errors.New("insufficient permissions") ErrDuplicateInvites = errors.New("duplicate invites") ErrIsOwner = errors.New("can't be made by owner") ErrIncorrectNumberOfAccounts = errors.New("incorrect number of accounts") ErrDuplicateAccounts = errors.New("duplicate accounts") ErrNoReadKey = errors.New("no read key") ErrIncorrectReadKey = errors.New("incorrect read key") ErrInvalidSignature = errors.New("signature is invalid") ErrIncorrectRoot = errors.New("incorrect root") ErrIncorrectRecordSequence = errors.New("incorrect prev id of a record") ErrMetadataTooLarge = errors.New("metadata size too large") ErrOwnerNotFound = errors.New("owner not found") )
View Source
var ( ErrIncorrectCID = errors.New("incorrect CID") ErrRecordAlreadyExists = errors.New("record already exists") )
Functions ¶
func WrapAclRecord ¶ added in v0.2.15
func WrapAclRecord(rawRec *consensusproto.RawRecord) *consensusproto.RawRecordWithId
Types ¶
type AccountAdd ¶ added in v0.3.18
type AccountAdd struct {
Identity crypto.PubKey
Permissions AclPermissions
Metadata []byte
}
type AccountRemovePayload ¶ added in v0.2.11
type AccountRemovePayload struct {
Identities []crypto.PubKey
Change ReadKeyChangePayload
}
type AccountState ¶ added in v0.3.18
type AccountState struct {
PubKey crypto.PubKey
Permissions AclPermissions
Status AclStatus
RequestMetadata []byte
KeyRecordId string
PermissionChanges []PermissionChange
}
type AccountsAddPayload ¶ added in v0.3.18
type AccountsAddPayload struct {
Additions []AccountAdd
}
type AclAccountState ¶ added in v0.2.15
type AclAccountState struct {
PubKey crypto.PubKey
Permissions AclPermissions
RequestMetadata []byte
KeyRecordId string
}
type AclList ¶
type AclList interface {
RWLocker
Id() string
Root() *consensusproto.RawRecordWithId
Records() []*AclRecord
AclState() *AclState
IsAfter(first string, second string) (bool, error)
HasHead(head string) bool
Head() *AclRecord
RecordsAfter(ctx context.Context, id string) (records []*consensusproto.RawRecordWithId, err error)
RecordsBefore(ctx context.Context, headId string) (records []*consensusproto.RawRecordWithId, err error)
Get(id string) (*AclRecord, error)
GetIndex(idx int) (*AclRecord, error)
Iterate(iterFunc IterFunc)
IterateFrom(startId string, iterFunc IterFunc)
KeyStorage() crypto.KeyStorage
RecordBuilder() AclRecordBuilder
ValidateRawRecord(rawRec *consensusproto.RawRecord, afterValid func(state *AclState) error) (err error)
AddRawRecord(rawRec *consensusproto.RawRecordWithId) (err error)
AddRawRecords(rawRecords []*consensusproto.RawRecordWithId) (err error)
Close(ctx context.Context) (err error)
}
func BuildAclListWithIdentity ¶
func BuildAclListWithIdentity(acc *accountdata.AccountKeys, storage Storage, verifier recordverifier.AcceptorVerifier) (AclList, error)
func NewInMemoryDerivedAcl ¶ added in v0.6.0
func NewInMemoryDerivedAcl(spaceId string, keys *accountdata.AccountKeys) (AclList, error)
type AclPermissions ¶ added in v0.2.11
type AclPermissions aclrecordproto.AclUserPermissions
func (AclPermissions) CanManageAccounts ¶ added in v0.2.11
func (p AclPermissions) CanManageAccounts() bool
func (AclPermissions) CanRequestRemove ¶ added in v0.6.8
func (p AclPermissions) CanRequestRemove() bool
func (AclPermissions) CanWrite ¶ added in v0.2.11
func (p AclPermissions) CanWrite() bool
func (AclPermissions) IsGuest ¶ added in v0.8.0
func (p AclPermissions) IsGuest() bool
func (AclPermissions) IsOwner ¶ added in v0.2.11
func (p AclPermissions) IsOwner() bool
func (AclPermissions) NoPermissions ¶ added in v0.2.11
func (p AclPermissions) NoPermissions() bool
type AclRecordBuilder ¶
type AclRecordBuilder interface {
UnmarshallWithId(rawIdRecord *consensusproto.RawRecordWithId) (rec *AclRecord, err error)
Unmarshall(rawRecord *consensusproto.RawRecord) (rec *AclRecord, err error)
BuildRoot(content RootContent) (rec *consensusproto.RawRecordWithId, err error)
BuildBatchRequest(payload BatchRequestPayload) (batchResult BatchResult, err error)
BuildInvite() (res InviteResult, err error)
BuildInviteAnyone(permissions AclPermissions) (res InviteResult, err error)
BuildInviteChange(inviteChange InviteChangePayload) (rawRecord *consensusproto.RawRecord, err error)
BuildInviteRevoke(inviteRecordId string) (rawRecord *consensusproto.RawRecord, err error)
BuildInviteJoin(payload InviteJoinPayload) (rawRecord *consensusproto.RawRecord, err error)
BuildRequestJoin(payload RequestJoinPayload) (rawRecord *consensusproto.RawRecord, err error)
BuildRequestAccept(payload RequestAcceptPayload) (rawRecord *consensusproto.RawRecord, err error)
BuildRequestDecline(requestRecordId string) (rawRecord *consensusproto.RawRecord, err error)
BuildRequestCancel(requestRecordId string) (rawRecord *consensusproto.RawRecord, err error)
BuildRequestRemove() (rawRecord *consensusproto.RawRecord, err error)
BuildPermissionChange(payload PermissionChangePayload) (rawRecord *consensusproto.RawRecord, err error)
BuildPermissionChanges(payload PermissionChangesPayload) (rawRecord *consensusproto.RawRecord, err error)
BuildReadKeyChange(payload ReadKeyChangePayload) (rawRecord *consensusproto.RawRecord, err error)
BuildAccountRemove(payload AccountRemovePayload) (rawRecord *consensusproto.RawRecord, err error)
BuildAccountsAdd(payload AccountsAddPayload) (rawRecord *consensusproto.RawRecord, err error)
}
func NewAclRecordBuilder ¶
func NewAclRecordBuilder(id string, keyStorage crypto.KeyStorage, keys *accountdata.AccountKeys, verifier recordverifier.AcceptorVerifier) AclRecordBuilder
type AclState ¶
type AclState struct {
// contains filtered or unexported fields
}
func NewTestAclStateWithUsers ¶ added in v0.4.0
func (*AclState) AccountKey ¶ added in v0.2.15
func (*AclState) ApplyRecord ¶ added in v0.3.26
func (*AclState) CurrentAccounts ¶ added in v0.3.21
func (st *AclState) CurrentAccounts() []AccountState
func (*AclState) CurrentMetadataKey ¶ added in v0.2.15
func (*AclState) CurrentReadKeyId ¶
func (*AclState) DecryptInvite ¶ added in v0.8.0
func (*AclState) FirstMetadataKey ¶ added in v0.7.2
func (*AclState) GetInviteIdByPrivKey ¶ added in v0.3.18
func (*AclState) GetMetadata ¶ added in v0.2.15
func (*AclState) HadReadPermissions ¶ added in v0.3.21
func (*AclState) Invites ¶ added in v0.3.20
func (st *AclState) Invites(inviteType ...aclrecordproto.AclInviteType) []Invite
func (*AclState) JoinRecord ¶ added in v0.3.18
func (*AclState) JoinRecords ¶ added in v0.2.11
func (st *AclState) JoinRecords(decrypt bool) (records []RequestRecord, err error)
func (*AclState) LastRecordId ¶
func (*AclState) OwnerPubKey ¶ added in v0.3.33
func (*AclState) Permissions ¶ added in v0.2.11
func (st *AclState) Permissions(identity crypto.PubKey) AclPermissions
func (*AclState) PermissionsAtRecord ¶ added in v0.3.18
func (*AclState) ReadKeyForAclId ¶ added in v0.7.0
func (*AclState) Record ¶ added in v0.3.20
func (st *AclState) Record(identity crypto.PubKey) (RequestRecord, error)
func (*AclState) RemoveRecords ¶ added in v0.2.11
func (st *AclState) RemoveRecords() (records []RequestRecord)
func (*AclState) RequestIds ¶ added in v0.8.0
func (*AclState) Validator ¶ added in v0.2.11
func (st *AclState) Validator() ContentValidator
type AclTestExecutor ¶ added in v0.3.20
type AclTestExecutor struct {
// contains filtered or unexported fields
}
func NewAclExecutor ¶ added in v0.3.20
func NewAclExecutor(spaceId string) *AclTestExecutor
func NewExternalKeysAclExecutor ¶ added in v0.5.0
func NewExternalKeysAclExecutor(spaceId string, keys *accountdata.AccountKeys, ownerMeta []byte, root *consensusproto.RawRecordWithId) *AclTestExecutor
func (*AclTestExecutor) ActualAccounts ¶ added in v0.3.20
func (a *AclTestExecutor) ActualAccounts() map[string]*TestAclState
func (*AclTestExecutor) Execute ¶ added in v0.3.20
func (a *AclTestExecutor) Execute(cmd string) (err error)
type BatchRequestPayload ¶ added in v0.3.26
type BatchRequestPayload struct {
Additions []AccountAdd
Changes []PermissionChangePayload
Removals AccountRemovePayload
Approvals []RequestAcceptPayload
Declines []string
InviteRevokes []string
InviteChanges []InviteChangePayload
NewInvites []AclPermissions
}
type BatchResult ¶ added in v0.8.0
type BatchResult struct {
Rec *consensusproto.RawRecord
Invites []crypto.PrivKey
}
type ContentValidator ¶ added in v0.2.11
type ContentValidator interface {
ValidateAclRecordContents(ch *AclRecord) (err error)
ValidatePermissionChange(ch *aclrecordproto.AclAccountPermissionChange, authorIdentity crypto.PubKey) (err error)
ValidatePermissionChanges(ch *aclrecordproto.AclAccountPermissionChanges, authorIdentity crypto.PubKey) (err error)
ValidateAccountsAdd(ch *aclrecordproto.AclAccountsAdd, authorIdentity crypto.PubKey) (err error)
ValidateInvite(ch *aclrecordproto.AclAccountInvite, authorIdentity crypto.PubKey) (err error)
ValidateInviteJoin(ch *aclrecordproto.AclAccountInviteJoin, authorIdentity crypto.PubKey) (err error)
ValidateInviteChange(ch *aclrecordproto.AclAccountInviteChange, authorIdentity crypto.PubKey) (err error)
ValidateInviteRevoke(ch *aclrecordproto.AclAccountInviteRevoke, authorIdentity crypto.PubKey) (err error)
ValidateRequestJoin(ch *aclrecordproto.AclAccountRequestJoin, authorIdentity crypto.PubKey) (err error)
ValidateRequestAccept(ch *aclrecordproto.AclAccountRequestAccept, authorIdentity crypto.PubKey) (err error)
ValidateRequestDecline(ch *aclrecordproto.AclAccountRequestDecline, authorIdentity crypto.PubKey) (err error)
ValidateRequestCancel(ch *aclrecordproto.AclAccountRequestCancel, authorIdentity crypto.PubKey) (err error)
ValidateAccountRemove(ch *aclrecordproto.AclAccountRemove, authorIdentity crypto.PubKey) (err error)
ValidateRequestRemove(ch *aclrecordproto.AclAccountRequestRemove, authorIdentity crypto.PubKey) (err error)
ValidateReadKeyChange(ch *aclrecordproto.AclReadKeyChange, authorIdentity crypto.PubKey) (err error)
}
type Invite ¶ added in v0.8.0
type Invite struct {
Key crypto.PubKey
Type aclrecordproto.AclInviteType
Permissions AclPermissions
Id string
// contains filtered or unexported fields
}
type InviteChangePayload ¶ added in v0.8.0
type InviteChangePayload struct {
IniviteRecordId string
Permissions AclPermissions
}
type InviteJoinPayload ¶ added in v0.8.0
type InviteResult ¶ added in v0.2.11
type InviteResult struct {
InviteRec *consensusproto.RawRecord
InviteKey crypto.PrivKey
}
type NewInvites ¶ added in v0.8.0
type NewInvites struct {
Permissions AclPermissions
}
type PermissionChange ¶ added in v0.3.18
type PermissionChange struct {
RecordId string
Permission AclPermissions
}
type PermissionChangePayload ¶ added in v0.2.11
type PermissionChangePayload struct {
Identity crypto.PubKey
Permissions AclPermissions
}
type PermissionChangesPayload ¶ added in v0.3.18
type PermissionChangesPayload struct {
Changes []PermissionChangePayload
}
type ReadKeyChangePayload ¶ added in v0.2.15
type RequestAcceptPayload ¶ added in v0.2.11
type RequestAcceptPayload struct {
RequestRecordId string
Permissions AclPermissions
}
type RequestJoinPayload ¶ added in v0.2.11
type RequestRecord ¶ added in v0.2.11
type RequestType ¶ added in v0.2.11
type RequestType int
const ( RequestTypeRemove RequestType = iota RequestTypeJoin )
type RootContent ¶
type Storage ¶ added in v0.6.0
type Storage interface {
Id() string
Root(ctx context.Context) (StorageRecord, error)
Head(ctx context.Context) (string, error)
Has(ctx context.Context, id string) (bool, error)
Get(ctx context.Context, id string) (StorageRecord, error)
GetAfterOrder(ctx context.Context, order int, iter StorageIterator) error
GetBeforeOrder(ctx context.Context, order int, iter StorageIterator) error
AddAll(ctx context.Context, records []StorageRecord) error
}
func CreateStorage ¶ added in v0.6.0
func CreateStorage(ctx context.Context, root *consensusproto.RawRecordWithId, headStorage headstorage.HeadStorage, store anystore.DB) (Storage, error)
func CreateStorageTx ¶ added in v0.6.3
func CreateStorageTx(ctx context.Context, root *consensusproto.RawRecordWithId, headStorage headstorage.HeadStorage, store anystore.DB) (Storage, error)
func NewInMemoryStorage ¶ added in v0.6.0
func NewInMemoryStorage( id string, records []*consensusproto.RawRecordWithId) (Storage, error)
func NewStorage ¶ added in v0.6.0
func NewStorage(ctx context.Context, id string, headStorage headstorage.HeadStorage, store anystore.DB) (Storage, error)
type StorageIterator ¶ added in v0.6.0
type StorageIterator = func(ctx context.Context, record StorageRecord) (shouldContinue bool, err error)
type StorageProvider ¶ added in v0.6.0
type StorageProvider func(root *consensusproto.RawRecordWithId) (Storage, error)
type StorageRecord ¶ added in v0.6.0
func (StorageRecord) RawRecordWithId ¶ added in v0.6.0
func (c StorageRecord) RawRecordWithId() *consensusproto.RawRecordWithId
type TestAclState ¶ added in v0.3.20
type TestAclState struct {
Keys *accountdata.AccountKeys
Acl AclList
}
type UserPermissionPair ¶
type UserPermissionPair struct {
Identity crypto.PubKey
Permission aclrecordproto.AclUserPermissions
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.