From 01b910fd317906bf323360f00d87d256f1b3101a Mon Sep 17 00:00:00 2001 From: alexvanin Date: Fri, 17 Jan 2020 14:56:51 +0300 Subject: [PATCH 1/2] session: Add public key to the constructor of new private token Private token based on the token with private key. Therefore it must inherit public key field through constructor parameter. --- session/service.go | 1 + session/store.go | 1 + session/store_test.go | 13 +++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/session/service.go b/session/service.go index 1695c04..d9f889f 100644 --- a/session/service.go +++ b/session/service.go @@ -33,6 +33,7 @@ type ( LastEpoch uint64 ObjectID []ObjectID OwnerID OwnerID + PublicKeys [][]byte } ) diff --git a/session/store.go b/session/store.go index f12943f..1daf151 100644 --- a/session/store.go +++ b/session/store.go @@ -54,6 +54,7 @@ func (s *simpleStore) New(p TokenParams) *PToken { LastEpoch: p.LastEpoch, ObjectID: p.ObjectID, OwnerID: p.OwnerID, + PublicKeys: p.PublicKeys, }, PrivateKey: key, } diff --git a/session/store_test.go b/session/store_test.go index 66f99d4..ade0cb0 100644 --- a/session/store_test.go +++ b/session/store_test.go @@ -57,9 +57,14 @@ func TestTokenStore(t *testing.T) { c := newTestClient(t) require.NotNil(t, c) + pk := [][]byte{crypto.MarshalPublicKey(&c.PublicKey)} // create new token - token := s.New(TokenParams{ObjectID: []ObjectID{oid}, OwnerID: c.OwnerID}) + token := s.New(TokenParams{ + ObjectID: []ObjectID{oid}, + OwnerID: c.OwnerID, + PublicKeys: pk, + }) signToken(t, token, c) // check that it can be fetched @@ -68,7 +73,11 @@ func TestTokenStore(t *testing.T) { require.Equal(t, token, t1) // create and sign another token by the same client - t1 = s.New(TokenParams{ObjectID: []ObjectID{oid}, OwnerID: c.OwnerID}) + t1 = s.New(TokenParams{ + ObjectID: []ObjectID{oid}, + OwnerID: c.OwnerID, + PublicKeys: pk}) + signToken(t, t1, c) data := []byte{1, 2, 3} From 0a2fd1dbc0f11a391901f4d5fedee817805ab0c2 Mon Sep 17 00:00:00 2001 From: alexvanin Date: Fri, 17 Jan 2020 15:08:21 +0300 Subject: [PATCH 2/2] Update changelog for v0.2.10 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc0bb81..cb2b4ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog This is the changelog for NeoFS Proto +## [0.2.10] - 2020-01-17 + +### Changed +- Private token contructor now takes public keys as an argument + ## [0.2.9] - 2020-01-17 ### Added @@ -106,3 +111,4 @@ Initial public release [0.2.7]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.6...v0.2.7 [0.2.8]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.7...v0.2.8 [0.2.9]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.8...v0.2.9 +[0.2.10]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.9...v0.2.10