-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbackend.go
56 lines (49 loc) · 1.09 KB
/
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
47
48
49
50
51
52
53
54
55
56
package vault_plugin_auth_tencentcloud
import (
"context"
"net/http"
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/logical"
)
// Factory
func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
client := cleanhttp.DefaultClient()
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}
b := newBackend(client)
if err := b.Setup(ctx, conf); err != nil {
return nil, err
}
return b, nil
}
func newBackend(client *http.Client) *backend {
b := &backend{
identityClient: client,
}
b.Backend = &framework.Backend{
AuthRenew: b.pathLoginRenew,
Help: backendHelp,
PathsSpecial: &logical.Paths{
Unauthenticated: []string{
"login",
},
},
Paths: []*framework.Path{
pathLogin(b),
pathListRole(b),
pathListRoles(b),
pathRole(b),
pathConfigClient(b),
},
BackendType: logical.TypeCredential,
}
return b
}
type backend struct {
*framework.Backend
identityClient *http.Client
}
const backendHelp = `
`