open-vault/builtin/logical/ssh/backend.go

72 lines
1.5 KiB
Go
Raw Normal View History

package ssh
import (
"strings"
2015-07-22 18:15:19 +00:00
"github.com/hashicorp/vault/helper/salt"
"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework"
)
func Factory(conf *logical.BackendConfig) (logical.Backend, error) {
2015-07-22 18:15:19 +00:00
b, err := Backend(conf)
if err != nil {
return nil, err
}
return b.Setup(conf)
}
2015-07-22 18:15:19 +00:00
func Backend(conf *logical.BackendConfig) (*framework.Backend, error) {
salt, err := salt.NewSalt(conf.View, nil)
if err != nil {
return nil, err
}
var b backend
2015-07-22 18:15:19 +00:00
b.salt = salt
b.Backend = &framework.Backend{
Help: strings.TrimSpace(backendHelp),
PathsSpecial: &logical.Paths{
Root: []string{
"config/*",
"keys/*",
},
Unauthenticated: []string{
"verify",
},
},
Paths: []*framework.Path{
pathConfigLease(&b),
pathKeys(&b),
pathRoles(&b),
2015-07-24 16:13:26 +00:00
pathCredsCreate(&b),
pathLookup(&b),
2015-07-22 18:15:19 +00:00
pathVerify(&b),
},
Secrets: []*framework.Secret{
secretDynamicKey(&b),
2015-07-22 18:15:19 +00:00
secretOTP(&b),
},
}
2015-07-22 18:15:19 +00:00
return b.Backend, nil
}
type backend struct {
*framework.Backend
2015-07-22 18:15:19 +00:00
salt *salt.Salt
}
const backendHelp = `
The SSH backend dynamically generates SSH private keys for
remote hosts.The generated key has a configurable lease set
and are automatically revoked at the end of the lease.
After mounting this backend, configure the lease using the
'config/lease' endpoint. The shared SSH key belonging to any
infrastructure should be registered with the 'roles/' endpoint
before dynamic keys for remote hosts can be generated.
`