credential/userpass: renewal

This commit is contained in:
Mitchell Hashimoto
2015-04-19 15:12:50 -07:00
parent 4eea0e237b
commit 0320cea5de
2 changed files with 18 additions and 0 deletions

View File

@@ -28,6 +28,8 @@ func Backend() *framework.Backend {
pathLogin(&b),
pathUsers(&b),
}),
AuthRenew: b.pathLoginRenew,
}
return b.Backend

View File

@@ -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.
`