macaroons: use constraint layer for macaroon tweaking

This commit is contained in:
whythat
2017-09-02 03:45:14 +03:00
committed by Olaoluwa Osuntokun
parent 5c3493bd30
commit a6b9155150
3 changed files with 25 additions and 30 deletions

8
lnd.go
View File

@@ -20,7 +20,6 @@ import (
"time"
"gopkg.in/macaroon-bakery.v1/bakery"
"gopkg.in/macaroon-bakery.v1/bakery/checkers"
"golang.org/x/net/context"
@@ -569,11 +568,8 @@ func genMacaroons(svc *bakery.Service, admFile, roFile string) error {
}
// Generate the read-only macaroon and write it to a file.
caveat := checkers.AllowCaveat(roPermissions...)
roMacaroon := admMacaroon.Clone()
if err = svc.AddCaveat(roMacaroon, caveat); err != nil {
return err
}
roMacaroon := macaroons.AddConstraints(admMacaroon,
macaroons.PermissionsConstraint(roPermissions...))
roBytes, err := roMacaroon.MarshalBinary()
if err != nil {
return err