-
Notifications
You must be signed in to change notification settings - Fork 566
/
backend.go
44 lines (40 loc) · 1.04 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
package pachyderm
import (
"context"
"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework"
)
type backend struct {
*framework.Backend
}
// Factory is the function that the Pachyderm Vault plugin exports to let Vault
// create/refresh/revoke Pachyderm tokens
func Factory(ctx context.Context, c *logical.BackendConfig) (logical.Backend, error) {
result := &backend{}
result.Backend = &framework.Backend{
BackendType: logical.TypeLogical,
PathsSpecial: &logical.Paths{
Unauthenticated: []string{"login"},
},
Paths: []*framework.Path{
result.configPath(),
result.loginPath(),
result.versionPath(),
},
Secrets: []*framework.Secret{{
Type: "pachyderm_tokens",
Fields: map[string]*framework.FieldSchema{
"user_token": &framework.FieldSchema{
Type: framework.TypeString,
Description: "Pachyderm authentication tokens",
},
},
Renew: result.Renew,
Revoke: result.Revoke,
}},
}
if err := result.Setup(ctx, c); err != nil {
return nil, err
}
return result, nil
}