mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
credential/userpass: renewal
This commit is contained in:
@@ -28,6 +28,8 @@ func Backend() *framework.Backend {
|
||||
pathLogin(&b),
|
||||
pathUsers(&b),
|
||||
}),
|
||||
|
||||
AuthRenew: b.pathLoginRenew,
|
||||
}
|
||||
|
||||
return b.Backend
|
||||
|
||||
@@ -2,6 +2,7 @@ package userpass
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/framework"
|
||||
@@ -55,6 +56,21 @@ func (b *backend) pathLogin(
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (b *backend) pathLoginRenew(
|
||||
req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
||||
// Get the user and validate auth
|
||||
user, err := b.User(req.Storage, req.Auth.Metadata["username"])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if user == nil {
|
||||
// User no longer exists, do not renew
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return framework.LeaseExtend(1*time.Hour, 0)(req, d)
|
||||
}
|
||||
|
||||
const pathLoginSyn = `
|
||||
Log in with a username and password.
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user