mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
Use RenewSelf instead of Renew if the token we're renewing is the same as the client
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/vault/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TokenRenewCommand is a Command that mounts a new mount.
|
// TokenRenewCommand is a Command that mounts a new mount.
|
||||||
@@ -47,7 +49,14 @@ func (c *TokenRenewCommand) Run(args []string) int {
|
|||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
secret, err := client.Auth().Token().Renew(token, increment)
|
// If the given token is the same as the client's, use renew-self instead
|
||||||
|
// as this is far more likely to be allowed via policy
|
||||||
|
var secret *api.Secret
|
||||||
|
if client.Token() == token {
|
||||||
|
secret, err = client.Auth().Token().RenewSelf(increment)
|
||||||
|
} else {
|
||||||
|
secret, err = client.Auth().Token().Renew(token, increment)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf(
|
c.Ui.Error(fmt.Sprintf(
|
||||||
"Error renewing token: %s", err))
|
"Error renewing token: %s", err))
|
||||||
|
|||||||
Reference in New Issue
Block a user