2018-10-09 16:29:20 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2019-01-09 00:48:57 +00:00
|
|
|
hclog "github.com/hashicorp/go-hclog"
|
2019-04-13 02:01:13 +00:00
|
|
|
"github.com/hashicorp/vault/api"
|
2018-10-09 16:29:20 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/totp"
|
2019-04-12 21:54:35 +00:00
|
|
|
"github.com/hashicorp/vault/sdk/plugin"
|
2018-10-09 16:29:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2019-04-15 18:10:07 +00:00
|
|
|
apiClientMeta := &api.PluginAPIClientMeta{}
|
2018-10-09 16:29:20 +00:00
|
|
|
flags := apiClientMeta.FlagSet()
|
|
|
|
flags.Parse(os.Args[1:])
|
|
|
|
|
|
|
|
tlsConfig := apiClientMeta.GetTLSConfig()
|
2019-04-12 21:54:35 +00:00
|
|
|
tlsProviderFunc := api.VaultPluginTLSProvider(tlsConfig)
|
2018-10-09 16:29:20 +00:00
|
|
|
|
|
|
|
if err := plugin.Serve(&plugin.ServeOpts{
|
|
|
|
BackendFactoryFunc: totp.Factory,
|
|
|
|
TLSProviderFunc: tlsProviderFunc,
|
|
|
|
}); err != nil {
|
|
|
|
logger := hclog.New(&hclog.LoggerOptions{})
|
|
|
|
|
|
|
|
logger.Error("plugin shutting down", "error", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|