This repository has been archived by the owner on Feb 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.go
71 lines (63 loc) · 1.69 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package oidc
import (
"context"
"strings"
"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework"
)
// Factory returns a new backend as logical.Backend.
func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := Backend()
if err := b.Setup(ctx, conf); err != nil {
return nil, err
}
return b, nil
}
// FactoryType is a wrapper func that allows the Factory func to specify
// the backend type for the mock backend plugin instance.
func FactoryType(backendType logical.BackendType) logical.Factory {
return func(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := Backend()
b.BackendType = backendType
if err := b.Setup(ctx, conf); err != nil {
return nil, err
}
return b, nil
}
}
// Backend returns a private embedded struct of framework.Backend.
func Backend() *backend {
var b backend
b.Backend = &framework.Backend{
Help: strings.TrimSpace(backendHelp),
//PeriodicFunc periodicFunc
Paths: framework.PathAppend(
[]*framework.Path{
pathConfig(&b),
pathUsers(&b),
pathGroups(&b),
pathUsersList(&b),
pathGroupsList(&b),
pathLogin(&b),
},
),
AuthRenew: nil, // explicitly don't support renewal.
PathsSpecial: &logical.Paths{
Unauthenticated: []string{
"login",
},
},
Secrets: []*framework.Secret{},
BackendType: logical.TypeLogical,
}
return &b
}
type backend struct {
*framework.Backend
}
const backendHelp = `
The OpenID Connect provider allows Vault to issue Tokens for
holders of OpenID Connect identity tokens, which are self validating.
Only users that have an explicit mapping of username or group to a policy
will be granted Tokens.
`