/
api.go
77 lines (64 loc) · 1.5 KB
/
api.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
72
73
74
75
76
77
package eventrecorder
import (
"crypto/x509"
"time"
"github.com/Symantec/Dominator/lib/log"
"golang.org/x/crypto/ssh"
)
const (
AuthTypeNone = iota
AuthTypePassword
AuthTypeSymantecVIP
AuthTypeU2F
)
const (
VIPAuthTypeOTP = iota
VIPAuthTypePush
)
type AuthInfo struct {
AuthType uint
Username string
VIPAuthType uint8
}
type Events struct {
ComputeTime time.Duration
Events EventsMap
}
type EventsMap map[string][]EventType // Key: username.
type eventsListType struct {
newest *eventType
oldest *eventType
}
type EventType struct {
AuthType uint
CreateTime uint64 // Seconds since Epoch.
LifetimeSeconds uint32
ServiceProviderUrl string
Ssh bool
WebLogin bool
X509 bool
VIPAuthType uint8
}
type eventType struct {
EventType
newer *eventType
older *eventType
}
type EventRecorder struct {
AuthChannel chan<- *AuthInfo
RequestEventsChannel chan<- chan<- Events
ServiceProviderLoginChannel chan<- *SPLoginInfo
SshCertChannel chan<- *ssh.Certificate
WebLoginChannel chan<- string
X509CertChannel chan<- *x509.Certificate
filename string
logger log.Logger
eventsMap map[string]*eventsListType // Key: username.
}
type SPLoginInfo struct {
URL string
Username string
}
func New(filename string, logger log.Logger) (*EventRecorder, error) {
return newEventRecorder(filename, logger)
}