macaroons: add SetRootKey method

This adds a SetRootKey method which can be used to set the default
macaroon root key to a specified value.
This commit is contained in:
Daniel McNally committed 2022-08-12 11:34:43 -04:00
1 parent 86e5f9d0db
commit 4b14226e81
3 files changed
+77

No files matched your search

+14
View File
@@ -68,6 +68,10 @@ type ExtendedRootKeyStore interface {
// GenerateNewRootKey calls the underlying root key store's
// GenerateNewRootKey and returns the result.
GenerateNewRootKey() error
// SetRootKey calls the underlying root key store's SetRootKey and
// returns the result.
SetRootKey(rootKey []byte) error
}
// Service encapsulates bakery.Bakery and adds a Close() method that zeroes the
@@ -300,6 +304,16 @@ func (svc *Service) GenerateNewRootKey() error {
return nil
}
// SetRootKey calls the underlying root key store's SetRootKey and returns the
// result.
func (svc *Service) SetRootKey(rootKey []byte) error {
if boltRKS, ok := svc.rks.(ExtendedRootKeyStore); ok {
return boltRKS.SetRootKey(rootKey)
}
return nil
}
// ChangePassword calls the underlying root key store's ChangePassword and
// returns the result.
func (svc *Service) ChangePassword(oldPw, newPw []byte) error {