2015-06-16 20:58:54 +00:00
|
|
|
package ssh
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hashicorp/vault/logical"
|
|
|
|
"github.com/hashicorp/vault/logical/framework"
|
|
|
|
)
|
|
|
|
|
2015-06-19 00:48:41 +00:00
|
|
|
const SecretSshHostKeyType = "secret_ssh_host_key_type"
|
2015-06-16 20:58:54 +00:00
|
|
|
|
|
|
|
func secretOneTimeKey(b *backend) *framework.Secret {
|
|
|
|
log.Printf("Vishal: ssh.secretPrivateKey\n")
|
|
|
|
return &framework.Secret{
|
2015-06-19 00:48:41 +00:00
|
|
|
Type: SecretSshHostKeyType,
|
2015-06-16 20:58:54 +00:00
|
|
|
Fields: map[string]*framework.FieldSchema{
|
|
|
|
"username": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Username in host",
|
|
|
|
},
|
|
|
|
"ip": &framework.FieldSchema{
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "ip address of host",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DefaultDuration: 1 * time.Hour,
|
|
|
|
DefaultGracePeriod: 10 * time.Minute,
|
2015-06-19 00:48:41 +00:00
|
|
|
Renew: b.secretPrivateKeyRenew,
|
2015-06-16 20:58:54 +00:00
|
|
|
Revoke: b.secretPrivateKeyRevoke,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-19 00:48:41 +00:00
|
|
|
func (b *backend) secretPrivateKeyRenew(req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
|
|
|
log.Printf("Vishal: ssh.secretPrivateKeyRenew\n")
|
|
|
|
lease, err := b.Lease(req.Storage)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if lease == nil {
|
|
|
|
lease = &configLease{Lease: 1 * time.Hour}
|
|
|
|
}
|
|
|
|
f := framework.LeaseExtend(lease.Lease, lease.LeaseMax, false)
|
|
|
|
return f(req, d)
|
|
|
|
}
|
|
|
|
|
2015-06-16 20:58:54 +00:00
|
|
|
func (b *backend) secretPrivateKeyRevoke(req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
|
|
|
log.Printf("Vishal: ssh.secretPrivateKeyRevoke\n")
|
2015-06-19 00:48:41 +00:00
|
|
|
//TODO: implement here
|
2015-06-16 20:58:54 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|