Change InviteId logic and add UserAdd to change builder

This commit is contained in:
mcrakhman 2022-07-12 20:25:13 +02:00 committed by Mikhail Iudin
parent df6f3659fd
commit dbfb8cbabc
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0
14 changed files with 258 additions and 127 deletions

View File

@ -652,6 +652,7 @@ type ACLChangeUserInvite struct {
EncryptPublicKey []byte `protobuf:"bytes,2,opt,name=encryptPublicKey,proto3" json:"encryptPublicKey,omitempty"` EncryptPublicKey []byte `protobuf:"bytes,2,opt,name=encryptPublicKey,proto3" json:"encryptPublicKey,omitempty"`
EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"`
Permissions ACLChangeUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=anytype.ACLChangeUserPermissions" json:"permissions,omitempty"` Permissions ACLChangeUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=anytype.ACLChangeUserPermissions" json:"permissions,omitempty"`
InviteId string `protobuf:"bytes,5,opt,name=InviteId,proto3" json:"InviteId,omitempty"`
} }
func (m *ACLChangeUserInvite) Reset() { *m = ACLChangeUserInvite{} } func (m *ACLChangeUserInvite) Reset() { *m = ACLChangeUserInvite{} }
@ -715,11 +716,18 @@ func (m *ACLChangeUserInvite) GetPermissions() ACLChangeUserPermissions {
return ACLChange_Admin return ACLChange_Admin
} }
func (m *ACLChangeUserInvite) GetInviteId() string {
if m != nil {
return m.InviteId
}
return ""
}
type ACLChangeUserJoin struct { type ACLChangeUserJoin struct {
Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"`
EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"`
AcceptSignature []byte `protobuf:"bytes,3,opt,name=acceptSignature,proto3" json:"acceptSignature,omitempty"` AcceptSignature []byte `protobuf:"bytes,3,opt,name=acceptSignature,proto3" json:"acceptSignature,omitempty"`
UserInviteChangeId string `protobuf:"bytes,4,opt,name=userInviteChangeId,proto3" json:"userInviteChangeId,omitempty"` UserInviteId string `protobuf:"bytes,4,opt,name=userInviteId,proto3" json:"userInviteId,omitempty"`
EncryptedReadKeys [][]byte `protobuf:"bytes,5,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,5,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"`
} }
@ -777,9 +785,9 @@ func (m *ACLChangeUserJoin) GetAcceptSignature() []byte {
return nil return nil
} }
func (m *ACLChangeUserJoin) GetUserInviteChangeId() string { func (m *ACLChangeUserJoin) GetUserInviteId() string {
if m != nil { if m != nil {
return m.UserInviteChangeId return m.UserInviteId
} }
return "" return ""
} }
@ -978,64 +986,64 @@ func init() {
} }
var fileDescriptor_ffc88c8445fc0f24 = []byte{ var fileDescriptor_ffc88c8445fc0f24 = []byte{
// 897 bytes of a gzipped FileDescriptorProto // 907 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcb, 0x6e, 0xeb, 0x44, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4d, 0x6f, 0xe3, 0x44,
0x18, 0xf6, 0x24, 0x6d, 0x1d, 0xff, 0x0e, 0x6d, 0x18, 0x75, 0x61, 0xf9, 0x14, 0x2b, 0x54, 0x5c, 0x18, 0xf6, 0x24, 0x6d, 0x1d, 0xbf, 0x0e, 0x6d, 0x18, 0xf5, 0x60, 0x79, 0x8b, 0x15, 0x2a, 0x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, 0xf4, 0xda, 0xe3, 0xa3, 0x67, 0xd7,
0x02, 0xeb, 0xd9, 0x4d, 0x60, 0xfd, 0x79, 0x13, 0x58, 0x5f, 0x75, 0xb2, 0x8b, 0x8b, 0x3d, 0xf5, 0x11, 0x7a, 0x7e, 0x1d, 0xa1, 0x3f, 0xaf, 0x23, 0xf4, 0xcb, 0x4d, 0xe4, 0x3c, 0xbf, 0x89, 0x9c,
0x6f, 0xf9, 0xf0, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0xc0, 0x2c, 0x4a, 0x84, 0x0a, 0x00, 0x3f, 0x6e, 0x22, 0xe7, 0x9b, 0x56, 0x7e, 0x71, 0xb1, 0xa7, 0xff, 0x6b, 0x3e, 0xfc, 0x3b, 0x00,
0x00, 0x00, 0xff, 0xff, 0xd3, 0xdf, 0xf9, 0x1b, 0x94, 0x0a, 0x00, 0x00,
} }
func (m *ACLChange) Marshal() (dAtA []byte, err error) { func (m *ACLChange) Marshal() (dAtA []byte, err error) {
@ -1614,6 +1622,13 @@ func (m *ACLChangeUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i _ = i
var l int var l int
_ = l _ = l
if len(m.InviteId) > 0 {
i -= len(m.InviteId)
copy(dAtA[i:], m.InviteId)
i = encodeVarintAclchanges(dAtA, i, uint64(len(m.InviteId)))
i--
dAtA[i] = 0x2a
}
if m.Permissions != 0 { if m.Permissions != 0 {
i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions)) i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions))
i-- i--
@ -1674,10 +1689,10 @@ func (m *ACLChangeUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) {
dAtA[i] = 0x2a dAtA[i] = 0x2a
} }
} }
if len(m.UserInviteChangeId) > 0 { if len(m.UserInviteId) > 0 {
i -= len(m.UserInviteChangeId) i -= len(m.UserInviteId)
copy(dAtA[i:], m.UserInviteChangeId) copy(dAtA[i:], m.UserInviteId)
i = encodeVarintAclchanges(dAtA, i, uint64(len(m.UserInviteChangeId))) i = encodeVarintAclchanges(dAtA, i, uint64(len(m.UserInviteId)))
i-- i--
dAtA[i] = 0x22 dAtA[i] = 0x22
} }
@ -2128,6 +2143,10 @@ func (m *ACLChangeUserInvite) Size() (n int) {
if m.Permissions != 0 { if m.Permissions != 0 {
n += 1 + sovAclchanges(uint64(m.Permissions)) n += 1 + sovAclchanges(uint64(m.Permissions))
} }
l = len(m.InviteId)
if l > 0 {
n += 1 + l + sovAclchanges(uint64(l))
}
return n return n
} }
@ -2149,7 +2168,7 @@ func (m *ACLChangeUserJoin) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovAclchanges(uint64(l)) n += 1 + l + sovAclchanges(uint64(l))
} }
l = len(m.UserInviteChangeId) l = len(m.UserInviteId)
if l > 0 { if l > 0 {
n += 1 + l + sovAclchanges(uint64(l)) n += 1 + l + sovAclchanges(uint64(l))
} }
@ -3881,6 +3900,38 @@ func (m *ACLChangeUserInvite) Unmarshal(dAtA []byte) error {
break break
} }
} }
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field InviteId", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAclchanges
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthAclchanges
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthAclchanges
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.InviteId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default: default:
iNdEx = preIndex iNdEx = preIndex
skippy, err := skipAclchanges(dAtA[iNdEx:]) skippy, err := skipAclchanges(dAtA[iNdEx:])
@ -4033,7 +4084,7 @@ func (m *ACLChangeUserJoin) Unmarshal(dAtA []byte) error {
iNdEx = postIndex iNdEx = postIndex
case 4: case 4:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field UserInviteChangeId", wireType) return fmt.Errorf("proto: wrong wireType = %d for field UserInviteId", wireType)
} }
var stringLen uint64 var stringLen uint64
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
@ -4061,7 +4112,7 @@ func (m *ACLChangeUserJoin) Unmarshal(dAtA []byte) error {
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.UserInviteChangeId = string(dAtA[iNdEx:postIndex]) m.UserInviteId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex iNdEx = postIndex
case 5: case 5:
if wireType != 2 { if wireType != 2 {

View File

@ -69,13 +69,14 @@ message ACLChange {
bytes encryptPublicKey = 2; bytes encryptPublicKey = 2;
repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user
UserPermissions permissions = 4; UserPermissions permissions = 4;
string InviteId = 5;
} }
message UserJoin { message UserJoin {
string identity = 1; string identity = 1;
bytes encryptionKey = 2; bytes encryptionKey = 2;
bytes acceptSignature = 3; // sign acceptPublicKey bytes acceptSignature = 3; // sign acceptPublicKey
string userInviteChangeId = 4; string userInviteId = 4;
repeated bytes encryptedReadKeys = 5; // the idea is that user should itself reencrypt the keys with the pub key repeated bytes encryptedReadKeys = 5; // the idea is that user should itself reencrypt the keys with the pub key
} }

View File

@ -41,8 +41,8 @@ func newACLState(
} }
} }
func newACLStateFromSnapshot( func newACLStateFromSnapshotChange(
snapshot *pb.ACLChangeACLSnapshot, snapshotChange *pb.ACLChange,
identity string, identity string,
encryptionKey keys.EncryptionPrivKey, encryptionKey keys.EncryptionPrivKey,
signingPubKeyDecoder keys.SigningPubKeyDecoder) (*ACLState, error) { signingPubKeyDecoder keys.SigningPubKeyDecoder) (*ACLState, error) {
@ -54,14 +54,18 @@ func newACLStateFromSnapshot(
userInvites: make(map[string]*pb.ACLChangeUserInvite), userInvites: make(map[string]*pb.ACLChangeUserInvite),
signingPubKeyDecoder: signingPubKeyDecoder, signingPubKeyDecoder: signingPubKeyDecoder,
} }
err := st.recreateFromSnapshot(snapshot) err := st.recreateFromSnapshotChange(snapshotChange)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return st, nil return st, nil
} }
func (st *ACLState) recreateFromSnapshot(snapshot *pb.ACLChangeACLSnapshot) error { func (st *ACLState) recreateFromSnapshotChange(snapshotChange *pb.ACLChange) error {
snapshot := snapshotChange.GetAclData().GetAclSnapshot()
if snapshot == nil {
return fmt.Errorf("could not create state from snapshot, because it is nil")
}
state := snapshot.AclState state := snapshot.AclState
for _, userState := range state.UserStates { for _, userState := range state.UserStates {
st.userStates[userState.Identity] = userState st.userStates[userState.Identity] = userState
@ -71,7 +75,6 @@ func (st *ACLState) recreateFromSnapshot(snapshot *pb.ACLChangeACLSnapshot) erro
if !exists { if !exists {
return ErrNoSuchUser return ErrNoSuchUser
} }
var lastKeyHash uint64
for _, key := range userState.EncryptedReadKeys { for _, key := range userState.EncryptedReadKeys {
key, hash, err := st.decryptReadKeyAndHash(key) key, hash, err := st.decryptReadKeyAndHash(key)
if err != nil { if err != nil {
@ -79,9 +82,8 @@ func (st *ACLState) recreateFromSnapshot(snapshot *pb.ACLChangeACLSnapshot) erro
} }
st.userReadKeys[hash] = key st.userReadKeys[hash] = key
lastKeyHash = hash
} }
st.currentReadKeyHash = lastKeyHash st.currentReadKeyHash = snapshotChange.CurrentReadKeyHash
if snapshot.GetAclState().GetInvites() != nil { if snapshot.GetAclState().GetInvites() != nil {
st.userInvites = snapshot.GetAclState().GetInvites() st.userInvites = snapshot.GetAclState().GetInvites()
} }
@ -101,21 +103,29 @@ func (st *ACLState) makeSnapshot() *pb.ACLChangeACLSnapshot {
}} }}
} }
func (st *ACLState) applyChange(changeId string, change *pb.ACLChange) error { func (st *ACLState) applyChange(change *pb.ACLChange) (err error) {
defer func() {
if err != nil {
return
}
st.currentReadKeyHash = change.CurrentReadKeyHash
}()
// we can't check this for the user which is joining, because it will not be in our list // we can't check this for the user which is joining, because it will not be in our list
if !st.isUserJoin(change) { if !st.isUserJoin(change) {
// we check signature when we add this to the Tree, so no need to do it here // we check signature when we add this to the Tree, so no need to do it here
if _, exists := st.userStates[change.Identity]; !exists { if _, exists := st.userStates[change.Identity]; !exists {
return ErrNoSuchUser err = ErrNoSuchUser
return
} }
if !st.hasPermission(change.Identity, pb.ACLChange_Admin) { if !st.hasPermission(change.Identity, pb.ACLChange_Admin) {
return fmt.Errorf("user %s must have admin permissions", change.Identity) err = fmt.Errorf("user %s must have admin permissions", change.Identity)
return
} }
} }
for _, ch := range change.GetAclData().GetAclContent() { for _, ch := range change.GetAclData().GetAclContent() {
if err := st.applyChangeContent(changeId, ch); err != nil { if err = st.applyChangeContent(ch); err != nil {
//log.Infof("error while applying changes: %v; ignore", err) //log.Infof("error while applying changes: %v; ignore", err)
return err return err
} }
@ -125,7 +135,7 @@ func (st *ACLState) applyChange(changeId string, change *pb.ACLChange) error {
} }
// TODO: remove changeId, because it is not needed // TODO: remove changeId, because it is not needed
func (st *ACLState) applyChangeContent(changeId string, ch *pb.ACLChangeACLContentValue) error { func (st *ACLState) applyChangeContent(ch *pb.ACLChangeACLContentValue) error {
switch { switch {
case ch.GetUserPermissionChange() != nil: case ch.GetUserPermissionChange() != nil:
return st.applyUserPermissionChange(ch.GetUserPermissionChange()) return st.applyUserPermissionChange(ch.GetUserPermissionChange())
@ -134,7 +144,7 @@ func (st *ACLState) applyChangeContent(changeId string, ch *pb.ACLChangeACLConte
case ch.GetUserRemove() != nil: case ch.GetUserRemove() != nil:
return st.applyUserRemove(ch.GetUserRemove()) return st.applyUserRemove(ch.GetUserRemove())
case ch.GetUserInvite() != nil: case ch.GetUserInvite() != nil:
return st.applyUserInvite(changeId, ch.GetUserInvite()) return st.applyUserInvite(ch.GetUserInvite())
case ch.GetUserJoin() != nil: case ch.GetUserJoin() != nil:
return st.applyUserJoin(ch.GetUserJoin()) return st.applyUserJoin(ch.GetUserJoin())
case ch.GetUserConfirm() != nil: case ch.GetUserConfirm() != nil:
@ -153,15 +163,15 @@ func (st *ACLState) applyUserPermissionChange(ch *pb.ACLChangeUserPermissionChan
return nil return nil
} }
func (st *ACLState) applyUserInvite(changeId string, ch *pb.ACLChangeUserInvite) error { func (st *ACLState) applyUserInvite(ch *pb.ACLChangeUserInvite) error {
st.userInvites[changeId] = ch st.userInvites[ch.InviteId] = ch
return nil return nil
} }
func (st *ACLState) applyUserJoin(ch *pb.ACLChangeUserJoin) error { func (st *ACLState) applyUserJoin(ch *pb.ACLChangeUserJoin) error {
invite, exists := st.userInvites[ch.UserInviteChangeId] invite, exists := st.userInvites[ch.UserInviteId]
if !exists { if !exists {
return fmt.Errorf("no such invite with id %s", ch.UserInviteChangeId) return fmt.Errorf("no such invite with id %s", ch.UserInviteId)
} }
if _, exists = st.userStates[ch.Identity]; exists { if _, exists = st.userStates[ch.Identity]; exists {
@ -190,7 +200,6 @@ func (st *ACLState) applyUserJoin(ch *pb.ACLChangeUserJoin) error {
// if ourselves -> we need to decrypt the read keys // if ourselves -> we need to decrypt the read keys
if st.identity == ch.Identity { if st.identity == ch.Identity {
var lastKeyHash uint64
for _, key := range ch.EncryptedReadKeys { for _, key := range ch.EncryptedReadKeys {
key, hash, err := st.decryptReadKeyAndHash(key) key, hash, err := st.decryptReadKeyAndHash(key)
if err != nil { if err != nil {
@ -198,9 +207,7 @@ func (st *ACLState) applyUserJoin(ch *pb.ACLChangeUserJoin) error {
} }
st.userReadKeys[hash] = key st.userReadKeys[hash] = key
lastKeyHash = hash
} }
st.currentReadKeyHash = lastKeyHash
} }
// adding user to the list // adding user to the list
@ -227,6 +234,17 @@ func (st *ACLState) applyUserAdd(ch *pb.ACLChangeUserAdd) error {
EncryptedReadKeys: ch.EncryptedReadKeys, EncryptedReadKeys: ch.EncryptedReadKeys,
} }
if ch.Identity == st.identity {
for _, key := range ch.EncryptedReadKeys {
key, hash, err := st.decryptReadKeyAndHash(key)
if err != nil {
return ErrFailedToDecrypt
}
st.userReadKeys[hash] = key
}
}
return nil return nil
} }

View File

@ -52,9 +52,8 @@ func (sb *aclStateBuilder) BuildBefore(beforeId string) (*ACLState, bool, error)
return nil, false, fmt.Errorf("root should always be a snapshot") return nil, false, fmt.Errorf("root should always be a snapshot")
} }
snapshot := root.Content.GetAclData().GetAclSnapshot() state, err := newACLStateFromSnapshotChange(
state, err := newACLStateFromSnapshot( root.Content,
snapshot,
sb.identity, sb.identity,
sb.key, sb.key,
sb.decoder) sb.decoder)
@ -99,7 +98,7 @@ func (sb *aclStateBuilder) BuildBefore(beforeId string) (*ACLState, bool, error)
idSeenMap[c.Content.Identity] = append(idSeenMap[c.Content.Identity], c) idSeenMap[c.Content.Identity] = append(idSeenMap[c.Content.Identity], c)
if c.Content.GetAclData() != nil { if c.Content.GetAclData() != nil {
err = state.applyChange(c.Id, c.Content) err = state.applyChange(c.Content)
if err != nil { if err != nil {
return false return false
} }

View File

@ -30,7 +30,7 @@ type TreeUpdateListener interface {
type ACLTree interface { type ACLTree interface {
ACLState() *ACLState ACLState() *ACLState
AddContent(f func(builder ChangeBuilder)) (*Change, error) AddContent(f func(builder ChangeBuilder) error) (*Change, error)
AddChanges(changes ...*Change) (AddResult, error) AddChanges(changes ...*Change) (AddResult, error)
Heads() []string Heads() []string
Root() *Change Root() *Change
@ -186,23 +186,21 @@ func (a *aclTree) ACLState() *ACLState {
return a.aclState return a.aclState
} }
func (a *aclTree) AddContent(build func(builder ChangeBuilder)) (*Change, error) { func (a *aclTree) AddContent(build func(builder ChangeBuilder) error) (*Change, error) {
// TODO: add snapshot creation logic // TODO: add snapshot creation logic
a.Lock() a.Lock()
defer a.Unlock() defer a.Unlock()
a.changeBuilder.Init(a.aclState, a.fullTree, a.accountData) a.changeBuilder.Init(a.aclState, a.fullTree, a.accountData)
build(a.changeBuilder) err := build(a.changeBuilder)
ch, marshalled, err := a.changeBuilder.Build()
if err != nil {
return nil, err
}
err = a.aclState.applyChange(ch.Id, ch.Content)
if err != nil { if err != nil {
return nil, err return nil, err
} }
ch, marshalled, err := a.changeBuilder.BuildAndApply()
if err != nil {
return nil, err
}
a.fullTree.AddFast(ch) a.fullTree.AddFast(ch)
err = a.thread.AddRawChange(&thread.RawChange{ err = a.thread.AddRawChange(&thread.RawChange{

View File

@ -6,12 +6,14 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
"github.com/textileio/go-threads/crypto/symmetric"
"hash/fnv"
) )
type MarshalledChange = []byte type MarshalledChange = []byte
type ACLChangeBuilder interface { type ACLChangeBuilder interface {
UserAdd(identity string, encryptionKey keys.EncryptionPubKey, permissions pb.ACLChangeUserPermissions) UserAdd(identity string, encryptionKey keys.EncryptionPubKey, permissions pb.ACLChangeUserPermissions) error
AddId(id string) // TODO: this is only for testing AddId(id string) // TODO: this is only for testing
SetMakeSnapshot(bool) // TODO: who should decide this? probably ACLTree so we can delete it SetMakeSnapshot(bool) // TODO: who should decide this? probably ACLTree so we can delete it
} }
@ -30,6 +32,8 @@ type changeBuilder struct {
changeContent proto.Marshaler changeContent proto.Marshaler
id string id string
makeSnapshot bool makeSnapshot bool
readKey *symmetric.Key
readKeyHash uint64
} }
func newChangeBuilder() *changeBuilder { func newChangeBuilder() *changeBuilder {
@ -42,6 +46,17 @@ func (c *changeBuilder) Init(state *ACLState, tree *Tree, acc *account.AccountDa
c.acc = acc c.acc = acc
c.aclData = &pb.ACLChangeACLData{} c.aclData = &pb.ACLChangeACLData{}
// setting read key for further encryption etc
if state.currentReadKeyHash == 0 {
c.readKey, _ = symmetric.NewRandom()
hasher := fnv.New64()
hasher.Write(c.readKey.Bytes())
c.readKeyHash = hasher.Sum64()
} else {
c.readKey = c.aclState.userReadKeys[c.aclState.currentReadKeyHash]
c.readKeyHash = c.aclState.currentReadKeyHash
}
} }
func (c *changeBuilder) AddId(id string) { func (c *changeBuilder) AddId(id string) {
@ -52,12 +67,44 @@ func (c *changeBuilder) SetMakeSnapshot(b bool) {
c.makeSnapshot = b c.makeSnapshot = b
} }
func (c *changeBuilder) UserAdd(identity string, encryptionKey keys.EncryptionPubKey, permissions pb.ACLChangeUserPermissions) { func (c *changeBuilder) UserAdd(identity string, encryptionKey keys.EncryptionPubKey, permissions pb.ACLChangeUserPermissions) error {
//TODO implement me var allKeys []*symmetric.Key
panic("implement me") if c.aclState.currentReadKeyHash != 0 {
for _, key := range c.aclState.userReadKeys {
allKeys = append(allKeys, key)
}
} else {
allKeys = append(allKeys, c.readKey)
} }
func (c *changeBuilder) Build() (*Change, []byte, error) { var encryptedKeys [][]byte
for _, k := range allKeys {
res, err := encryptionKey.Encrypt(k.Bytes())
if err != nil {
return err
}
encryptedKeys = append(encryptedKeys, res)
}
rawKey, err := encryptionKey.Raw()
if err != nil {
return err
}
ch := &pb.ACLChangeACLContentValue{
Value: &pb.ACLChangeACLContentValueValueOfUserAdd{
UserAdd: &pb.ACLChangeUserAdd{
Identity: identity,
EncryptionKey: rawKey,
EncryptedReadKeys: encryptedKeys,
Permissions: permissions,
},
},
}
c.aclData.AclContent = append(c.aclData.AclContent, ch)
return nil
}
func (c *changeBuilder) BuildAndApply() (*Change, []byte, error) {
marshalled, err := c.changeContent.Marshal() marshalled, err := c.changeContent.Marshal()
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -69,10 +116,6 @@ func (c *changeBuilder) Build() (*Change, []byte, error) {
return nil, nil, err return nil, nil, err
} }
if c.makeSnapshot {
c.aclData.AclSnapshot = c.aclState.makeSnapshot()
}
aclChange := &pb.ACLChange{ aclChange := &pb.ACLChange{
TreeHeadIds: c.tree.Heads(), TreeHeadIds: c.tree.Heads(),
AclHeadIds: c.tree.ACLHeads(), AclHeadIds: c.tree.ACLHeads(),
@ -83,6 +126,14 @@ func (c *changeBuilder) Build() (*Change, []byte, error) {
Timestamp: 0, Timestamp: 0,
Identity: c.acc.Identity, Identity: c.acc.Identity,
} }
err = c.aclState.applyChange(aclChange)
if err != nil {
return nil, nil, err
}
if c.makeSnapshot {
c.aclData.AclSnapshot = c.aclState.makeSnapshot()
}
fullMarshalledChange, err := proto.Marshal(aclChange) fullMarshalledChange, err := proto.Marshal(aclChange)
if err != nil { if err != nil {

View File

@ -41,7 +41,7 @@ func (s *snapshotValidator) ValidateSnapshot(ch *Change) (bool, error) {
return false, fmt.Errorf("didn't find snapshot in ACL Tree") return false, fmt.Errorf("didn't find snapshot in ACL Tree")
} }
otherSt, err := newACLStateFromSnapshot(ch.Content.GetAclData().GetAclSnapshot(), s.identity, s.key, s.decoder) otherSt, err := newACLStateFromSnapshotChange(ch.Content, s.identity, s.key, s.decoder)
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@ -8,17 +8,20 @@ import (
func BuildThreadWithACL( func BuildThreadWithACL(
acc *account.AccountData, acc *account.AccountData,
build func(builder ChangeBuilder), build func(builder ChangeBuilder) error,
create func(change *thread.RawChange) (thread.Thread, error)) (thread.Thread, error) { create func(change *thread.RawChange) (thread.Thread, error)) (thread.Thread, error) {
bld := newChangeBuilder() bld := newChangeBuilder()
bld.Init( bld.Init(
newACLState(acc.Identity, acc.EncKey, keys.NewEd25519Decoder()), newACLState(acc.Identity, acc.EncKey, keys.NewEd25519Decoder()),
&Tree{}, &Tree{},
acc) acc)
build(bld) err := build(bld)
if err != nil {
return nil, err
}
bld.SetMakeSnapshot(true) bld.SetMakeSnapshot(true)
change, payload, err := bld.Build() change, payload, err := bld.BuildAndApply()
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -27,13 +27,14 @@ func (p *plainTextDocument) Text() string {
} }
func (p *plainTextDocument) AddText(text string) error { func (p *plainTextDocument) AddText(text string) error {
_, err := p.aclTree.AddContent(func(builder acltree.ChangeBuilder) { _, err := p.aclTree.AddContent(func(builder acltree.ChangeBuilder) error {
builder.AddChangeContent( builder.AddChangeContent(
&pb.PlainTextChangeData{ &pb.PlainTextChangeData{
Content: []*pb.PlainTextChangeContent{ Content: []*pb.PlainTextChangeContent{
createAppendTextChangeContent(text), createAppendTextChangeContent(text),
}, },
}) })
return nil
}) })
return err return err
} }
@ -114,9 +115,13 @@ func NewPlainTextDocument(
acc *account.AccountData, acc *account.AccountData,
create func(change *thread.RawChange) (thread.Thread, error), create func(change *thread.RawChange) (thread.Thread, error),
text string) (PlainTextDocument, error) { text string) (PlainTextDocument, error) {
changeBuilder := func(builder acltree.ChangeBuilder) { changeBuilder := func(builder acltree.ChangeBuilder) error {
builder.UserAdd(acc.Identity, acc.EncKey.GetPublic(), aclpb.ACLChange_Admin) err := builder.UserAdd(acc.Identity, acc.EncKey.GetPublic(), aclpb.ACLChange_Admin)
if err != nil {
return err
}
builder.AddChangeContent(createInitialChangeContent(text)) builder.AddChangeContent(createInitialChangeContent(text))
return nil
} }
t, err := acltree.BuildThreadWithACL( t, err := acltree.BuildThreadWithACL(
acc, acc,

View File

@ -370,7 +370,7 @@ func (t *ThreadBuilder) parseACLChange(ch *ACLChange) (convCh *pb.ACLChangeACLCo
Identity: t.keychain.GetIdentity(join.Identity), Identity: t.keychain.GetIdentity(join.Identity),
EncryptionKey: rawKey, EncryptionKey: rawKey,
AcceptSignature: signature, AcceptSignature: signature,
UserInviteChangeId: join.InviteId, UserInviteId: join.InviteId,
EncryptedReadKeys: t.encryptReadKeys(join.EncryptedReadKeys, encKey), EncryptedReadKeys: t.encryptReadKeys(join.EncryptedReadKeys, encKey),
}, },
}, },
@ -389,6 +389,7 @@ func (t *ThreadBuilder) parseACLChange(ch *ACLChange) (convCh *pb.ACLChangeACLCo
EncryptPublicKey: rawEncKey, EncryptPublicKey: rawEncKey,
EncryptedReadKeys: t.encryptReadKeys(invite.EncryptedReadKeys, encKey), EncryptedReadKeys: t.encryptReadKeys(invite.EncryptedReadKeys, encKey),
Permissions: t.convertPermission(invite.Permissions), Permissions: t.convertPermission(invite.Permissions),
InviteId: invite.InviteId,
}, },
}, },
} }

View File

@ -45,6 +45,7 @@ type ACLChange struct {
EncryptionKey string `yaml:"encryptionKey"` EncryptionKey string `yaml:"encryptionKey"`
EncryptedReadKeys []string `yaml:"encryptedReadKeys"` EncryptedReadKeys []string `yaml:"encryptedReadKeys"`
Permissions string `yaml:"permissions"` Permissions string `yaml:"permissions"`
InviteId string `yaml:"inviteId"`
} `yaml:"userInvite"` } `yaml:"userInvite"`
UserConfirm *struct { UserConfirm *struct {

View File

@ -29,6 +29,7 @@ changes:
encryptionKey: key.Enc.Onetime1 encryptionKey: key.Enc.Onetime1
encryptedReadKeys: [key.Read.1] encryptedReadKeys: [key.Read.1]
permissions: writer permissions: writer
inviteId: A.1.2
- userAdd: - userAdd:
identity: C identity: C
permission: reader permission: reader

View File

@ -29,6 +29,7 @@ changes:
encryptionKey: key.Enc.Onetime1 encryptionKey: key.Enc.Onetime1
encryptedReadKeys: [key.Read.1] encryptedReadKeys: [key.Read.1]
permissions: writer permissions: writer
inviteId: A.1.2
- userAdd: - userAdd:
identity: C identity: C
permission: reader permission: reader

View File

@ -29,6 +29,7 @@ changes:
encryptionKey: key.Enc.Onetime1 encryptionKey: key.Enc.Onetime1
encryptedReadKeys: [key.Read.1] encryptedReadKeys: [key.Read.1]
permissions: writer permissions: writer
inviteId: A.1.2
readKey: key.Read.1 readKey: key.Read.1
- id: A.1.3 - id: A.1.3
identity: A identity: A