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

81 lines
1.8 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"
)
2015-07-29 18:21:36 +00:00
type backend struct {
*framework.Backend
salt *salt.Salt
}
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.StorageView, &salt.Config{
HashFunc: salt.SHA256Hash,
})
2015-07-22 18:15:19 +00:00
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{
pathConfigZeroAddress(&b),
pathKeys(&b),
2016-01-28 17:48:00 +00:00
pathListRoles(&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
}
const backendHelp = `
The SSH backend generates credentials allowing clients to establish SSH
connections to remote hosts.
There are two variants of the backend, which generate different types of
credentials: dynamic keys and One-Time Passwords (OTPs). The desired behavior
is role-specific and chosen at role creation time with the 'key_type'
parameter.
2015-07-27 17:02:31 +00:00
Please see the backend documentation for a thorough description of both
types. The Vault team strongly recommends the OTP type.
2015-07-27 17:02:31 +00:00
After mounting this backend, before generating credentials, configure the
backend's lease behavior using the 'config/lease' endpoint and create roles
using the 'roles/' endpoint.
`