This repository was archived by the owner on Nov 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbackend.go
More file actions
69 lines (58 loc) · 1.26 KB
/
backend.go
File metadata and controls
69 lines (58 loc) · 1.26 KB
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
package kerberos
import (
"context"
"encoding/json"
"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework"
)
const (
configPath string = "config"
)
type backend struct {
*framework.Backend
}
func Factory(ctx context.Context, c *logical.BackendConfig) (logical.Backend, error) {
b := Backend()
if err := b.Setup(ctx, c); err != nil {
return nil, err
}
return b, nil
}
func Backend() *backend {
b := &backend{}
b.Backend = &framework.Backend{
BackendType: logical.TypeCredential,
Help: backendHelp,
PathsSpecial: &logical.Paths{
Unauthenticated: []string{"login"},
SealWrapStorage: []string{configPath},
},
Paths: framework.PathAppend(
[]*framework.Path{
pathConfig(b),
pathConfigLdap(b),
pathLogin(b),
pathGroups(b),
pathGroupsList(b),
},
),
}
return b
}
func (b *backend) config(ctx context.Context, s logical.Storage) (*kerberosConfig, error) {
raw, err := s.Get(ctx, configPath)
if err != nil {
return nil, err
}
if raw == nil {
return nil, nil
}
conf := &kerberosConfig{}
if err := json.Unmarshal(raw.Value, conf); err != nil {
return nil, err
}
return conf, nil
}
var backendHelp string = `
The Kerberos Auth Backend allows authentication via Kerberos SPNEGO.
`