2015-08-27 15:51:35 +00:00
|
|
|
package logical
|
|
|
|
|
2017-02-16 18:37:21 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hashicorp/vault/helper/consts"
|
|
|
|
)
|
2015-08-27 15:51:35 +00:00
|
|
|
|
2015-08-27 17:36:44 +00:00
|
|
|
// SystemView exposes system configuration information in a safe way
|
|
|
|
// for logical backends to consume
|
|
|
|
type SystemView interface {
|
2015-08-27 16:14:03 +00:00
|
|
|
// DefaultLeaseTTL returns the default lease TTL set in Vault configuration
|
2015-09-10 19:09:34 +00:00
|
|
|
DefaultLeaseTTL() time.Duration
|
2015-08-27 16:14:03 +00:00
|
|
|
|
|
|
|
// MaxLeaseTTL returns the max lease TTL set in Vault configuration; backend
|
|
|
|
// authors should take care not to issue credentials that last longer than
|
|
|
|
// this value, as Vault will revoke them
|
2015-09-10 19:09:34 +00:00
|
|
|
MaxLeaseTTL() time.Duration
|
2015-09-18 23:59:06 +00:00
|
|
|
|
2015-09-21 14:04:03 +00:00
|
|
|
// SudoPrivilege returns true if given path has sudo privileges
|
|
|
|
// for the given client token
|
|
|
|
SudoPrivilege(path string, token string) bool
|
2016-01-22 22:01:22 +00:00
|
|
|
|
|
|
|
// Returns true if the mount is tainted. A mount is tainted if it is in the
|
|
|
|
// process of being unmounted. This should only be used in special
|
|
|
|
// circumstances; a primary use-case is as a guard in revocation functions.
|
|
|
|
// If revocation of a backend's leases fails it can keep the unmounting
|
|
|
|
// process from being successful. If the reason for this failure is not
|
|
|
|
// relevant when the mount is tainted (for instance, saving a CRL to disk
|
|
|
|
// when the stored CRL will be removed during the unmounting process
|
|
|
|
// anyways), we can ignore the errors to allow unmounting to complete.
|
|
|
|
Tainted() bool
|
2016-04-21 13:52:42 +00:00
|
|
|
|
|
|
|
// Returns true if caching is disabled. If true, no caches should be used,
|
|
|
|
// despite known slowdowns.
|
2016-04-21 20:32:06 +00:00
|
|
|
CachingDisabled() bool
|
2017-01-07 23:18:22 +00:00
|
|
|
|
2017-01-13 19:51:10 +00:00
|
|
|
// ReplicationState indicates the state of cluster replication
|
2017-02-16 18:37:21 +00:00
|
|
|
ReplicationState() consts.ReplicationState
|
2015-08-27 17:36:44 +00:00
|
|
|
}
|
|
|
|
|
2015-08-27 18:25:07 +00:00
|
|
|
type StaticSystemView struct {
|
2017-01-13 19:51:10 +00:00
|
|
|
DefaultLeaseTTLVal time.Duration
|
|
|
|
MaxLeaseTTLVal time.Duration
|
|
|
|
SudoPrivilegeVal bool
|
|
|
|
TaintedVal bool
|
|
|
|
CachingDisabledVal bool
|
|
|
|
Primary bool
|
2017-02-16 18:37:21 +00:00
|
|
|
ReplicationStateVal consts.ReplicationState
|
2015-08-27 17:36:44 +00:00
|
|
|
}
|
|
|
|
|
2015-09-10 19:09:34 +00:00
|
|
|
func (d StaticSystemView) DefaultLeaseTTL() time.Duration {
|
|
|
|
return d.DefaultLeaseTTLVal
|
2015-08-27 17:36:44 +00:00
|
|
|
}
|
|
|
|
|
2015-09-10 19:09:34 +00:00
|
|
|
func (d StaticSystemView) MaxLeaseTTL() time.Duration {
|
|
|
|
return d.MaxLeaseTTLVal
|
2015-08-27 15:51:35 +00:00
|
|
|
}
|
2015-09-18 23:59:06 +00:00
|
|
|
|
2015-09-21 14:04:03 +00:00
|
|
|
func (d StaticSystemView) SudoPrivilege(path string, token string) bool {
|
2015-09-19 21:53:24 +00:00
|
|
|
return d.SudoPrivilegeVal
|
2015-09-18 23:59:06 +00:00
|
|
|
}
|
2016-01-22 22:01:22 +00:00
|
|
|
|
|
|
|
func (d StaticSystemView) Tainted() bool {
|
|
|
|
return d.TaintedVal
|
|
|
|
}
|
2016-04-21 13:52:42 +00:00
|
|
|
|
2016-04-21 20:32:06 +00:00
|
|
|
func (d StaticSystemView) CachingDisabled() bool {
|
|
|
|
return d.CachingDisabledVal
|
2016-04-21 13:52:42 +00:00
|
|
|
}
|
2017-01-07 23:18:22 +00:00
|
|
|
|
2017-02-16 18:37:21 +00:00
|
|
|
func (d StaticSystemView) ReplicationState() consts.ReplicationState {
|
2017-01-13 19:51:10 +00:00
|
|
|
return d.ReplicationStateVal
|
2017-01-07 23:18:22 +00:00
|
|
|
}
|