GetOwners returns labels on the encryption too

This commit is contained in:
Zi Lin
2017-01-03 19:22:52 -08:00
committed by Kyle Isom
parent 1a1d8dec00
commit 43ffe45e72
2 changed files with 11 additions and 4 deletions

View File

@@ -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)
}

View File

@@ -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
}