Handle the various valid root cases
This commit is contained in:
parent
d810e1c432
commit
d64ef28c39
|
@ -485,21 +485,35 @@ func (v *vaultClient) parseSelfToken() error {
|
|||
}
|
||||
}
|
||||
|
||||
if !data.Renewable && !root {
|
||||
if !root {
|
||||
// All non-root tokens must be renewable
|
||||
if !data.Renewable {
|
||||
return fmt.Errorf("Vault token is not renewable or root")
|
||||
}
|
||||
|
||||
if data.CreationTTL == 0 && !root {
|
||||
// All non-root tokens must have a lease duration
|
||||
if data.CreationTTL == 0 {
|
||||
return fmt.Errorf("invalid lease duration of zero")
|
||||
}
|
||||
|
||||
if data.TTL == 0 && !root {
|
||||
// The lease duration can not be expired
|
||||
if data.TTL == 0 {
|
||||
return fmt.Errorf("token TTL is zero")
|
||||
}
|
||||
|
||||
if !root && data.Role == "" {
|
||||
// There must be a valid role
|
||||
if data.Role == "" {
|
||||
return fmt.Errorf("token role name must be set when not using a root token")
|
||||
}
|
||||
} else if data.CreationTTL != 0 {
|
||||
// If the root token has a TTL it must be renewable
|
||||
if !data.Renewable {
|
||||
return fmt.Errorf("Vault token has a TTL but is not renewable")
|
||||
} else if data.TTL == 0 {
|
||||
// If the token has a TTL make sure it has not expired
|
||||
return fmt.Errorf("token TTL is zero")
|
||||
}
|
||||
}
|
||||
|
||||
data.Root = root
|
||||
v.tokenData = &data
|
||||
|
|
Loading…
Reference in New Issue