From 43ffe45e725d824bc260f59280b2d50be58a9204 Mon Sep 17 00:00:00 2001 From: Zi Lin Date: Tue, 3 Jan 2017 19:22:52 -0800 Subject: [PATCH] GetOwners returns labels on the encryption too --- core/core.go | 12 +++++++++--- cryptor/cryptor.go | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/core.go b/core/core.go index be6fafc..1d6c645 100644 --- a/core/core.go +++ b/core/core.go @@ -172,6 +172,7 @@ type DecryptWithDelegates struct { type OwnersData struct { Status string Owners []string + Labels []string Predicate string } @@ -774,12 +775,17 @@ func Owners(jsonIn []byte) ([]byte, error) { return jsonStatusError(err) } - names, predicate, err := crypt.GetOwners(s.Data) + names, labels, predicate, err := crypt.GetOwners(s.Data) if err != nil { return jsonStatusError(err) } - return json.Marshal(OwnersData{Status: "ok", Owners: names, Predicate: predicate}) + return json.Marshal(OwnersData{ + Status: "ok", + Owners: names, + Predicate: predicate, + Labels: labels, + }) } // Export returns a backed up vault. @@ -834,7 +840,7 @@ func Order(jsonIn []byte) (out []byte, err error) { } // Get the owners of the ciphertext. - owners, _, err := crypt.GetOwners(o.EncryptedData) + owners, _, _, err := crypt.GetOwners(o.EncryptedData) if err != nil { return jsonStatusError(err) } diff --git a/cryptor/cryptor.go b/cryptor/cryptor.go index 9ae2ec0..cb88ccf 100644 --- a/cryptor/cryptor.go +++ b/cryptor/cryptor.go @@ -607,7 +607,7 @@ func (c *Cryptor) decrypt(cache *keycache.Cache, in []byte, user string) (resp [ // GetOwners returns the list of users that can delegate their passwords // to decrypt the given encrypted secret. -func (c *Cryptor) GetOwners(in []byte) (names []string, predicate string, err error) { +func (c *Cryptor) GetOwners(in []byte) (names, labels []string, predicate string, err error) { // unwrap encrypted file var encrypted EncryptedData if err = json.Unmarshal(in, &encrypted); err != nil { @@ -661,6 +661,7 @@ func (c *Cryptor) GetOwners(in []byte) (names []string, predicate string, err er } } predicate = encrypted.Predicate + labels = encrypted.Labels return }