2016-03-15 20:12:55 +00:00
|
|
|
package userpass
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hashicorp/vault/logical"
|
|
|
|
"github.com/hashicorp/vault/logical/framework"
|
|
|
|
)
|
|
|
|
|
|
|
|
func pathUserPassword(b *backend) *framework.Path {
|
|
|
|
return &framework.Path{
|
2016-03-15 20:46:12 +00:00
|
|
|
Pattern: "users/" + framework.GenericNameRegex("name") + "/password$",
|
2016-03-15 20:12:55 +00:00
|
|
|
Fields: map[string]*framework.FieldSchema{
|
|
|
|
"name": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Username for this user.",
|
|
|
|
},
|
|
|
|
|
|
|
|
"password": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Password for this user.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
|
|
|
logical.UpdateOperation: b.pathUserPasswordUpdate,
|
|
|
|
},
|
|
|
|
|
|
|
|
HelpSynopsis: pathUserPasswordHelpSyn,
|
|
|
|
HelpDescription: pathUserPasswordHelpDesc,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *backend) pathUserPasswordUpdate(
|
|
|
|
req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
|
|
|
password := d.Get("password").(string)
|
|
|
|
if password == "" {
|
|
|
|
return nil, fmt.Errorf("missing password")
|
|
|
|
}
|
2016-03-15 21:32:39 +00:00
|
|
|
return b.userCreateUpdate(req, d)
|
2016-03-15 20:12:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const pathUserPasswordHelpSyn = `
|
|
|
|
Reset user's password.
|
|
|
|
`
|
|
|
|
|
|
|
|
const pathUserPasswordHelpDesc = `
|
|
|
|
This endpoint allows resetting the user's password.
|
|
|
|
`
|