macaroons: use constraint layer for macaroon tweaking

This commit is contained in:
whythat authored and Olaoluwa Osuntokun committed 2017-09-19 16:46:20 -07:00
1 parent 5c3493bd30
commit a6b9155150
3 files changed
+25 -30

No files matched your search

+2 -6
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