-
Notifications
You must be signed in to change notification settings - Fork 2
/
auth.go
75 lines (59 loc) · 1.52 KB
/
auth.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
package pulsar
import (
"net/http"
"github.com/pkg/errors"
)
type Certificate struct {
}
type PrivateKey interface {
}
type AuthenticationDataProvider interface {
HasDataForTls() bool
GetTlsCertificates() []Certificate
GetTlsPrivateKey() PrivateKey
HasDataForHttp() bool
GetHttpAuthType() string
GetHttpHeaders() http.Header
HasDataFromCommand() bool
GetCommandData() string
}
type defaultAuthenticationDataProvider struct {
}
func (p *defaultAuthenticationDataProvider) HasDataForTls() bool {
return false
}
func (p *defaultAuthenticationDataProvider) GetTlsCertificates() []Certificate {
return nil
}
func (p *defaultAuthenticationDataProvider) GetTlsPrivateKey() PrivateKey {
return nil
}
func (p *defaultAuthenticationDataProvider) HasDataForHttp() bool {
return false
}
func (p *defaultAuthenticationDataProvider) GetHttpAuthType() string {
return ""
}
func (p *defaultAuthenticationDataProvider) GetHttpHeaders() http.Header {
return nil
}
func (p *defaultAuthenticationDataProvider) HasDataFromCommand() bool {
return false
}
func (p *defaultAuthenticationDataProvider) GetCommandData() string {
return ""
}
type Authentication interface {
GetAuthMethodName() string
GetAuthData() (AuthenticationDataProvider, error)
Configure(map[string]string)
Start() error
}
func NewAuthentication(name string, config *Config) (auth Authentication, err error) {
if name == OptionsAuthMethodAthenz {
auth = NewAuthenticationAthenz(config)
} else {
err = errors.Errorf("unsupport auth method: %s", name)
}
return
}