open-vault/vault/expiration.go
2015-03-12 12:44:30 -07:00

37 lines
1 KiB
Go

package vault
const (
// expirationSubPath is the sub-path used for the expiration manager
// view. This is nested under the system view.
expirationSubPath = "expire/"
)
// ExpirationManager is used by the Core to manage leases. Secrets
// can provide a lease, meaning that they can be renewed or revoked.
// If a secret is not renewed in timely manner, it may be expired, and
// the ExpirationManager will handle doing automatic revocation.
type ExpirationManager struct {
view *BarrierView
}
// NewExpirationManager creates a new ExpirationManager that is backed
// using a given view.
func NewExpirationManager(view *BarrierView) *ExpirationManager {
exp := &ExpirationManager{
view: view,
}
return exp
}
// setupExpiration is invoked after we've loaded the mount table to
// initialize the expiration manager
func (c *Core) setupExpiration() error {
// Create a sub-view
view := c.systemView.SubView(expirationSubPath)
// Create the manager
mgr := NewExpirationManager(view)
c.expiration = mgr
return nil
}