mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-16 23:11:11 +01:00
logical/framework: can specify renew/revoke functins for secret
This commit is contained in:
parent
813873b115
commit
6c1ecc8a15
@ -27,17 +27,17 @@ type Backend struct {
|
|||||||
Paths []*Path
|
Paths []*Path
|
||||||
PathsRoot []string
|
PathsRoot []string
|
||||||
|
|
||||||
|
// Secrets is the list of secret types that this backend can
|
||||||
|
// return. It is used to automatically generate proper responses,
|
||||||
|
// and ease specifying callbacks for revocation, renewal, etc.
|
||||||
|
Secrets []*Secret
|
||||||
|
|
||||||
// Rollback is called when a WAL entry (see wal.go) has to be rolled
|
// Rollback is called when a WAL entry (see wal.go) has to be rolled
|
||||||
// back. It is called with the data from the entry. Boolean true should
|
// back. It is called with the data from the entry. Boolean true should
|
||||||
// be returned on success. Errors should just be logged.
|
// be returned on success. Errors should just be logged.
|
||||||
Rollback func(kind string, data interface{}) bool
|
Rollback func(kind string, data interface{}) bool
|
||||||
RollbackMinAge time.Duration
|
RollbackMinAge time.Duration
|
||||||
|
|
||||||
// Secrets is the list of secret types that this backend can
|
|
||||||
// return. It is used to automatically generate proper responses,
|
|
||||||
// and ease specifying callbacks for revocation, renewal, etc.
|
|
||||||
Secrets []*Secret
|
|
||||||
|
|
||||||
once sync.Once
|
once sync.Once
|
||||||
pathsRe []*regexp.Regexp
|
pathsRe []*regexp.Regexp
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,14 +21,19 @@ type Secret struct {
|
|||||||
// the structure of this secret.
|
// the structure of this secret.
|
||||||
Fields map[string]*FieldSchema
|
Fields map[string]*FieldSchema
|
||||||
|
|
||||||
// Renewable is whether or not this secret type can be renewed.
|
|
||||||
Renewable bool
|
|
||||||
|
|
||||||
// DefaultDuration and DefaultGracePeriod are the default values for
|
// DefaultDuration and DefaultGracePeriod are the default values for
|
||||||
// the duration of the lease for this secret and its grace period. These
|
// the duration of the lease for this secret and its grace period. These
|
||||||
// can be manually overwritten with the result of Response().
|
// can be manually overwritten with the result of Response().
|
||||||
DefaultDuration time.Duration
|
DefaultDuration time.Duration
|
||||||
DefaultGracePeriod time.Duration
|
DefaultGracePeriod time.Duration
|
||||||
|
|
||||||
|
// Below are the operations that can be called on the secret.
|
||||||
|
//
|
||||||
|
// Renew, if not set, will mark the secret as not renewable.
|
||||||
|
//
|
||||||
|
// Revoke is required.
|
||||||
|
Renew OperationFunc
|
||||||
|
Revoke OperationFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// SecretType is the type of the secret with the given ID.
|
// SecretType is the type of the secret with the given ID.
|
||||||
@ -53,7 +58,7 @@ func (s *Secret) Response(
|
|||||||
IsSecret: true,
|
IsSecret: true,
|
||||||
Lease: &logical.Lease{
|
Lease: &logical.Lease{
|
||||||
VaultID: id,
|
VaultID: id,
|
||||||
Renewable: s.Renewable,
|
Renewable: s.Renew != nil,
|
||||||
Duration: s.DefaultDuration,
|
Duration: s.DefaultDuration,
|
||||||
GracePeriod: s.DefaultGracePeriod,
|
GracePeriod: s.DefaultGracePeriod,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user