1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"context"
"fmt"
"os"
"sync"
"github.com/openbao/openbao/sdk/v2/framework"
"github.com/openbao/openbao/sdk/v2/logical"
"github.com/openbao/openbao/sdk/v2/plugin"
)
const proveNamespace = "prove-sshd"
type backend struct {
*framework.Backend
lock sync.Mutex
}
func factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := &backend{}
b.Backend = &framework.Backend{
Help: "Logs a guest in by an sshsig made with its bound ed25519 ssh host key.",
BackendType: logical.TypeCredential,
PathsSpecial: &logical.Paths{
Unauthenticated: []string{"bind", "challenge", "login"},
},
Paths: []*framework.Path{
pathRoleList(b),
pathRole(b),
pathBind(b),
pathChallenge(b),
pathLogin(b),
},
AuthRenew: b.loginRenew,
}
if err := b.Setup(ctx, conf); err != nil {
return nil, err
}
return b, nil
}
func main() {
if err := plugin.ServeMultiplex(&plugin.ServeOpts{BackendFactoryFunc: factory}); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}