/
backend.go
46 lines (40 loc) · 939 Bytes
/
backend.go
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
package huaweicloud
import (
"context"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/logical"
"github.com/pkg/errors"
)
func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := newBackend()
if err := b.Setup(ctx, conf); err != nil {
return nil, errors.Wrapf(err, "failed to create factory")
}
return b, nil
}
func newBackend() *backend {
b := &backend{}
b.Backend = &framework.Backend{
AuthRenew: b.pathLoginRenew,
Help: backendHelp,
PathsSpecial: &logical.Paths{
Unauthenticated: []string{
"login",
},
},
Paths: []*framework.Path{
pathLogin(b),
pathListRoles(b),
pathRole(b),
},
BackendType: logical.TypeCredential,
}
return b
}
type backend struct {
*framework.Backend
}
const backendHelp = `
The Huawei Cloud auth method allows entities to authenticate based on their
personal token and pre-configured role.
`