1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-07 21:47:02 +09:00

Implement iinvite join and tests

This commit is contained in:
Mikhail Rakhmanov 2025-05-11 16:42:51 +02:00
parent 33a586c1af
commit ab01e874bb
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B
7 changed files with 207 additions and 146 deletions

View file

@ -204,9 +204,10 @@ func (m *AclRoot) GetEncryptedOwnerMetadata() []byte {
// AclAccountInvite contains the public invite key, the private part of which is sent to the user directly
type AclAccountInvite struct {
InviteKey []byte `protobuf:"bytes,1,opt,name=inviteKey,proto3" json:"inviteKey,omitempty"`
InviteType AclInviteType `protobuf:"varint,2,opt,name=inviteType,proto3,enum=aclrecord.AclInviteType" json:"inviteType,omitempty"`
Permissions AclUserPermissions `protobuf:"varint,3,opt,name=permissions,proto3,enum=aclrecord.AclUserPermissions" json:"permissions,omitempty"`
InviteKey []byte `protobuf:"bytes,1,opt,name=inviteKey,proto3" json:"inviteKey,omitempty"`
InviteType AclInviteType `protobuf:"varint,2,opt,name=inviteType,proto3,enum=aclrecord.AclInviteType" json:"inviteType,omitempty"`
Permissions AclUserPermissions `protobuf:"varint,3,opt,name=permissions,proto3,enum=aclrecord.AclUserPermissions" json:"permissions,omitempty"`
EncryptedReadKey []byte `protobuf:"bytes,4,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"`
}
func (m *AclAccountInvite) Reset() { *m = AclAccountInvite{} }
@ -271,6 +272,13 @@ func (m *AclAccountInvite) GetPermissions() AclUserPermissions {
return AclUserPermissions_None
}
func (m *AclAccountInvite) GetEncryptedReadKey() []byte {
if m != nil {
return m.EncryptedReadKey
}
return nil
}
// AclAccountRequestJoin contains the reference to the invite record and the data of the person who wants to join, confirmed by the private invite key
type AclAccountRequestJoin struct {
InviteIdentity []byte `protobuf:"bytes,1,opt,name=inviteIdentity,proto3" json:"inviteIdentity,omitempty"`
@ -1489,78 +1497,78 @@ func init() {
}
var fileDescriptor_c8e9f754f34e929b = []byte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 0x7f, 0x3b, 0xed, 0xa8, 0x27, 0xa7, 0x1d, 0xf5, 0x9f, 0xd3,
0x8e, 0xfa, 0xd3, 0x59, 0x47, 0x39, 0x39, 0xeb, 0x28, 0x7f, 0x9e, 0x75, 0x94, 0xaf, 0x6e, 0xae,
0xf5, 0x2d, 0x7a, 0xbc, 0x29, 0x7e, 0x3e, 0xfa, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x75, 0x08, 0x98,
0x61, 0xbb, 0x0e, 0x00, 0x00,
}
func (m *AclRoot) Marshal() (dAtA []byte, err error) {
@ -1667,6 +1675,13 @@ func (m *AclAccountInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.EncryptedReadKey) > 0 {
i -= len(m.EncryptedReadKey)
copy(dAtA[i:], m.EncryptedReadKey)
i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKey)))
i--
dAtA[i] = 0x22
}
if m.Permissions != 0 {
i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions))
i--
@ -2682,6 +2697,10 @@ func (m *AclAccountInvite) Size() (n int) {
if m.Permissions != 0 {
n += 1 + sovAclrecord(uint64(m.Permissions))
}
l = len(m.EncryptedReadKey)
if l > 0 {
n += 1 + l + sovAclrecord(uint64(l))
}
return n
}
@ -3579,6 +3598,40 @@ func (m *AclAccountInvite) Unmarshal(dAtA []byte) error {
break
}
}
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKey", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAclrecord
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthAclrecord
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthAclrecord
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.EncryptedReadKey = append(m.EncryptedReadKey[:0], dAtA[iNdEx:postIndex]...)
if m.EncryptedReadKey == nil {
m.EncryptedReadKey = []byte{}
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipAclrecord(dAtA[iNdEx:])

View file

@ -20,6 +20,7 @@ message AclAccountInvite {
bytes inviteKey = 1;
AclInviteType inviteType = 2;
AclUserPermissions permissions = 3;
bytes encryptedReadKey = 4;
}
enum AclInviteType {

View file

@ -28,7 +28,6 @@ type RequestJoinPayload struct {
type InviteJoinPayload struct {
InviteKey crypto.PrivKey
ReadKey crypto.SymKey
Metadata []byte
}
@ -89,6 +88,7 @@ type AclRecordBuilder interface {
BuildInvite() (res InviteResult, err error)
BuildInviteAnyone() (res InviteResult, 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)
@ -334,10 +334,23 @@ func (a *aclRecordBuilder) BuildInviteAnyone() (res InviteResult, err error) {
if err != nil {
return
}
curReadKey, err := a.state.CurrentReadKey()
if err != nil {
return
}
raw, err := curReadKey.Marshall()
if err != nil {
return
}
encReadKey, err := pubKey.Encrypt(raw)
if err != nil {
return
}
inviteRec := &aclrecordproto.AclAccountInvite{
InviteKey: invitePubKey,
InviteType: aclrecordproto.AclInviteType_AnyoneCanJoin,
Permissions: aclrecordproto.AclUserPermissions_Reader,
InviteKey: invitePubKey,
InviteType: aclrecordproto.AclInviteType_AnyoneCanJoin,
Permissions: aclrecordproto.AclUserPermissions_Reader,
EncryptedReadKey: encReadKey,
}
content := &aclrecordproto.AclContentValue{Value: &aclrecordproto.AclContentValue_Invite{Invite: inviteRec}}
rawRec, err := a.buildRecord(content)
@ -463,7 +476,11 @@ func (a *aclRecordBuilder) BuildInviteJoin(payload InviteJoinPayload) (rawRecord
if err != nil {
return
}
readKey, err := payload.ReadKey.Marshall()
key, err := a.state.DecryptInvite(payload.InviteKey)
if err != nil {
return
}
readKey, err := key.Marshall()
if err != nil {
return
}

View file

@ -55,9 +55,10 @@ type AclKeys struct {
}
type Invite struct {
Key crypto.PubKey
Type aclrecordproto.AclInviteType
Permissions AclPermissions
Key crypto.PubKey
Type aclrecordproto.AclInviteType
Permissions AclPermissions
encryptedKey []byte
}
type AclState struct {
@ -250,69 +251,20 @@ func (st *AclState) RequestIds() []string {
return requests
}
func (st *AclState) DecryptInvite(invitePk crypto.PrivKey) (keys AclKeys, err error) {
func (st *AclState) DecryptInvite(invitePk crypto.PrivKey) (key crypto.SymKey, err error) {
if invitePk == nil {
return AclKeys{}, ErrNoReadKey
return nil, ErrNoReadKey
}
var recId string
for id, invite := range st.invites {
for _, invite := range st.invites {
if invite.Key.Equals(invitePk.GetPublic()) {
recId = id
}
}
if recId == "" {
return AclKeys{}, ErrNoSuchInvite
}
currentKey := st.CurrentReadKeyId()
currentRec, err := st.list.Get(currentKey)
if err != nil {
return AclKeys{}, err
}
model, ok := currentRec.Model.(*aclrecordproto.AclData)
if !ok {
return AclKeys{}, ErrNoReadKey
}
var value *aclrecordproto.AclReadKeyChange
for _, ch := range model.GetAclContent() {
if ch.GetAccountRemove() != nil {
value = ch.GetReadKeyChange()
break
} else if ch.GetReadKeyChange() != nil {
value = ch.GetReadKeyChange()
break
}
}
if value == nil {
return AclKeys{}, ErrNoReadKey
}
mkPubKey, err := st.keyStore.PubKeyFromProto(value.MetadataPubKey)
if err != nil {
return AclKeys{}, err
}
keys = AclKeys{
MetadataPubKey: mkPubKey,
}
for _, key := range value.InviteKeys {
invKey, err := st.keyStore.PubKeyFromProto(key.Identity)
if err != nil {
return AclKeys{}, err
}
if invitePk.Equals(invKey) {
keys.ReadKey, err = st.unmarshallDecryptReadKey(key.EncryptedReadKey, invitePk.Decrypt)
res, err := st.unmarshallDecryptReadKey(invite.encryptedKey, invitePk.Decrypt)
if err != nil {
return AclKeys{}, err
return nil, err
}
break
return res, nil
}
}
if keys.ReadKey == nil {
return AclKeys{}, ErrNoReadKey
}
keys.MetadataPrivKey, err = st.unmarshallDecryptPrivKey(value.EncryptedMetadataPrivKey, keys.ReadKey.Decrypt)
if err != nil {
return AclKeys{}, err
}
return keys, nil
return nil, ErrNoSuchInvite
}
func (st *AclState) ApplyRecord(record *AclRecord) (err error) {
@ -544,9 +496,10 @@ func (st *AclState) applyInvite(ch *aclrecordproto.AclAccountInvite, record *Acl
return err
}
st.invites[record.Id] = Invite{
Key: inviteKey,
Type: ch.InviteType,
Permissions: AclPermissions(ch.Permissions),
Key: inviteKey,
Type: ch.InviteType,
Permissions: AclPermissions(ch.Permissions),
encryptedKey: ch.EncryptedReadKey,
}
return nil
}
@ -677,7 +630,7 @@ func (st *AclState) applyRequestAccept(ch *aclrecordproto.AclAccountRequestAccep
return st.unpackAllKeys(ch.EncryptedReadKey)
}
func (st *AclState) applyInviteJoin(ch *aclrecordproto.AclInviteJoin, record *AclRecord) error {
func (st *AclState) applyInviteJoin(ch *aclrecordproto.AclAccountInviteJoin, record *AclRecord) error {
err := st.contentValidator.ValidateInviteJoin(ch, record.Identity)
if err != nil {
return err
@ -716,7 +669,10 @@ func (st *AclState) applyInviteJoin(ch *aclrecordproto.AclInviteJoin, record *Ac
}),
}
}
return st.unpackAllKeys(ch.EncryptedReadKey)
if st.pubKey.Equals(identity) {
return st.unpackAllKeys(ch.EncryptedReadKey)
}
return nil
}
func (st *AclState) unpackAllKeys(rk []byte) error {
@ -870,6 +826,19 @@ func (st *AclState) applyReadKeyChange(ch *aclrecordproto.AclReadKeyChange, reco
aclKeys.ReadKey = res
}
}
for _, encKey := range ch.InviteKeys {
invKey, err := st.keyStore.PubKeyFromProto(encKey.Identity)
if err != nil {
return err
}
for key, invite := range st.invites {
if invite.Key.Equals(invKey) {
invite.encryptedKey = encKey.EncryptedReadKey
st.invites[key] = invite
break
}
}
}
if aclKeys.ReadKey != nil {
metadataKey, err := st.unmarshallDecryptPrivKey(ch.EncryptedMetadataPrivKey, aclKeys.ReadKey.Decrypt)
if err != nil {

View file

@ -498,6 +498,21 @@ func (a *AclTestExecutor) Execute(cmd string) (err error) {
if err != nil {
return err
}
case "invite_join":
invite := a.invites[args[0]]
inviteJoin, err := acl.RecordBuilder().BuildInviteJoin(InviteJoinPayload{
InviteKey: invite,
Metadata: []byte(account),
})
if err != nil {
return err
}
err = addRec(WrapAclRecord(inviteJoin))
if err != nil {
return err
}
a.expectedAccounts[account].status = StatusActive
a.expectedAccounts[account].perms = AclPermissions(aclrecordproto.AclUserPermissions_Reader)
case "remove":
identities := strings.Split(args[0], ",")
var pubKeys []crypto.PubKey

View file

@ -128,6 +128,9 @@ func TestAclExecutor(t *testing.T) {
{"a.changes::guest,none", ErrInsufficientPermissions},
// can't change permission of existing user to guest, should be only possible to create it with add
{"a.changes::r,g", ErrInsufficientPermissions},
{"a.invite_anyone::invAnyoneId", nil},
{"new.invite_join::invAnyoneId", nil},
{"new1.invite_join::invAnyoneId", nil},
}
for _, cmd := range cmds {
err := a.Execute(cmd.cmd)

View file

@ -13,7 +13,7 @@ type ContentValidator interface {
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.AclInviteJoin, authorIdentity crypto.PubKey) (err error)
ValidateInviteJoin(ch *aclrecordproto.AclAccountInviteJoin, 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)
@ -69,7 +69,7 @@ func (c *contentValidator) ValidateAccountsAdd(ch *aclrecordproto.AclAccountsAdd
return nil
}
func (c *contentValidator) ValidateInviteJoin(ch *aclrecordproto.AclInviteJoin, authorIdentity crypto.PubKey) (err error) {
func (c *contentValidator) ValidateInviteJoin(ch *aclrecordproto.AclAccountInviteJoin, authorIdentity crypto.PubKey) (err error) {
if !c.aclState.Permissions(authorIdentity).NoPermissions() {
return ErrInsufficientPermissions
}
@ -104,6 +104,9 @@ func (c *contentValidator) ValidateInviteJoin(ch *aclrecordproto.AclInviteJoin,
if len(ch.Metadata) > MaxMetadataLen {
return ErrMetadataTooLarge
}
if ch.EncryptedReadKey == nil {
return ErrIncorrectReadKey
}
return nil
}