2015-04-16 00:08:12 +00:00
|
|
|
package transit
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/vault/logical"
|
|
|
|
"github.com/hashicorp/vault/logical/framework"
|
|
|
|
)
|
|
|
|
|
2015-07-01 00:45:20 +00:00
|
|
|
func Factory(conf *logical.BackendConfig) (logical.Backend, error) {
|
2016-04-21 20:32:06 +00:00
|
|
|
b := Backend(conf)
|
2016-01-27 21:24:11 +00:00
|
|
|
be, err := b.Backend.Setup(conf)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return be, nil
|
2015-04-16 00:08:12 +00:00
|
|
|
}
|
|
|
|
|
2016-04-21 20:32:06 +00:00
|
|
|
func Backend(conf *logical.BackendConfig) *backend {
|
2015-04-16 00:08:12 +00:00
|
|
|
var b backend
|
|
|
|
b.Backend = &framework.Backend{
|
|
|
|
Paths: []*framework.Path{
|
2015-09-17 22:49:50 +00:00
|
|
|
// Rotate/Config needs to come before Keys
|
2015-09-14 20:28:46 +00:00
|
|
|
// as the handler is greedy
|
2016-02-02 14:26:25 +00:00
|
|
|
b.pathConfig(),
|
2016-01-27 21:24:11 +00:00
|
|
|
b.pathRotate(),
|
|
|
|
b.pathRewrap(),
|
|
|
|
b.pathKeys(),
|
|
|
|
b.pathEncrypt(),
|
|
|
|
b.pathDecrypt(),
|
|
|
|
b.pathDatakey(),
|
2015-04-16 00:08:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
Secrets: []*framework.Secret{},
|
|
|
|
}
|
|
|
|
|
2016-04-26 15:39:19 +00:00
|
|
|
b.lm = newLockManager(conf.System.CachingDisabled())
|
2016-01-27 21:24:11 +00:00
|
|
|
|
|
|
|
return &b
|
2015-04-16 00:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type backend struct {
|
|
|
|
*framework.Backend
|
2016-04-26 15:39:19 +00:00
|
|
|
lm *lockManager
|
2015-04-16 00:08:12 +00:00
|
|
|
}
|