mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-07 21:47:02 +09:00
Update record verifier
This commit is contained in:
parent
c2de5ecb12
commit
854823d81e
6 changed files with 9 additions and 16 deletions
|
@ -59,7 +59,7 @@ func (a *aclObject) AddConsensusRecords(recs []*consensusproto.RawRecordWithId)
|
||||||
if a.store, a.consErr = list.NewInMemoryStorage(a.id, recs); a.consErr != nil {
|
if a.store, a.consErr = list.NewInMemoryStorage(a.id, recs); a.consErr != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if a.AclList, a.consErr = list.BuildAclListWithIdentity(a.aclService.accountService.Account(), a.store, recordverifier.NewValidateFull()); a.consErr != nil {
|
if a.AclList, a.consErr = list.BuildAclListWithIdentity(a.aclService.accountService.Account(), a.store, recordverifier.New()); a.consErr != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -61,7 +61,7 @@ func (c *aclJoiningClient) getAcl(ctx context.Context, spaceId string) (l list.A
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return list.BuildAclListWithIdentity(c.keys, storage, recordverifier.NewValidateFull())
|
return list.BuildAclListWithIdentity(c.keys, storage, recordverifier.New())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *aclJoiningClient) CancelJoin(ctx context.Context, spaceId string) (err error) {
|
func (c *aclJoiningClient) CancelJoin(ctx context.Context, spaceId string) (err error) {
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (a *aclWaiter) loop(ctx context.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
acl, err := list.BuildAclListWithIdentity(a.keys, storage, recordverifier.NewValidateFull())
|
acl, err := list.BuildAclListWithIdentity(a.keys, storage, recordverifier.New())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
"github.com/anyproto/any-sync/app"
|
"github.com/anyproto/any-sync/app"
|
||||||
"github.com/anyproto/any-sync/consensus/consensusproto"
|
"github.com/anyproto/any-sync/consensus/consensusproto"
|
||||||
"github.com/anyproto/any-sync/nodeconf"
|
|
||||||
"github.com/anyproto/any-sync/util/crypto"
|
"github.com/anyproto/any-sync/util/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,20 +21,16 @@ type RecordVerifier interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() RecordVerifier {
|
func New() RecordVerifier {
|
||||||
return &recordVerifier{}
|
return &recordVerifier{
|
||||||
|
store: crypto.NewKeyStorage(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type recordVerifier struct {
|
type recordVerifier struct {
|
||||||
configuration nodeconf.NodeConf
|
store crypto.KeyStorage
|
||||||
networkKey crypto.PubKey
|
|
||||||
store crypto.KeyStorage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *recordVerifier) Init(a *app.App) (err error) {
|
func (r *recordVerifier) Init(a *app.App) (err error) {
|
||||||
r.configuration = a.MustComponent(nodeconf.CName).(nodeconf.NodeConf)
|
|
||||||
r.store = crypto.NewKeyStorage()
|
|
||||||
networkId := r.configuration.Configuration().NetworkId
|
|
||||||
r.networkKey, err = crypto.DecodeNetworkId(networkId)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
"github.com/anyproto/any-sync/app"
|
"github.com/anyproto/any-sync/app"
|
||||||
"github.com/anyproto/any-sync/consensus/consensusproto"
|
"github.com/anyproto/any-sync/consensus/consensusproto"
|
||||||
"github.com/anyproto/any-sync/nodeconf/testconf"
|
|
||||||
"github.com/anyproto/any-sync/testutil/accounttest"
|
"github.com/anyproto/any-sync/testutil/accounttest"
|
||||||
"github.com/anyproto/any-sync/util/crypto"
|
"github.com/anyproto/any-sync/util/crypto"
|
||||||
)
|
)
|
||||||
|
@ -22,9 +21,8 @@ type fixture struct {
|
||||||
func newFixture(t *testing.T) *fixture {
|
func newFixture(t *testing.T) *fixture {
|
||||||
accService := &accounttest.AccountTestService{}
|
accService := &accounttest.AccountTestService{}
|
||||||
a := &app.App{}
|
a := &app.App{}
|
||||||
verifier := &recordVerifier{}
|
verifier := New().(*recordVerifier)
|
||||||
a.Register(accService).
|
a.Register(accService).
|
||||||
Register(&testconf.StubConf{}).
|
|
||||||
Register(verifier)
|
Register(verifier)
|
||||||
require.NoError(t, a.Start(context.Background()))
|
require.NoError(t, a.Start(context.Background()))
|
||||||
return &fixture{
|
return &fixture{
|
||||||
|
|
|
@ -32,7 +32,7 @@ func migrateAclList(ctx context.Context, oldStorage oldstorage.ListStorage, head
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("migration: failed to generate keys: %w", err)
|
return nil, fmt.Errorf("migration: failed to generate keys: %w", err)
|
||||||
}
|
}
|
||||||
aclList, err := list.BuildAclListWithIdentity(keys, aclStorage, recordverifier.NewValidateFull())
|
aclList, err := list.BuildAclListWithIdentity(keys, aclStorage, recordverifier.New())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("migration: failed to build acl list: %w", err)
|
return nil, fmt.Errorf("migration: failed to build acl list: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue