forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
service.go
57 lines (46 loc) · 1.44 KB
/
service.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
package noauth
import (
"log"
"github.com/influxdata/kapacitor/auth"
)
// Provide an implentation of an Authentication service.
// NOTE: This service provides no real authentication but rather
// returns admin users for all requests.
type Service struct {
logger *log.Logger
}
func NewService(l *log.Logger) *Service {
return &Service{
logger: l,
}
}
func (s *Service) Open() error {
return nil
}
func (s *Service) Close() error {
return nil
}
// Return a user will all privileges and given username.
// NOTE: Password is ignored as no real authentication is performed.
func (s *Service) Authenticate(username, password string) (auth.User, error) {
return s.User(username)
}
// Return a user will all privileges and given username.
func (s *Service) User(username string) (auth.User, error) {
s.logger.Println("W! using noauth auth backend. Faked authentication for user", username)
return auth.NewUser(username, nil, true, nil), nil
}
// Return a user will all privileges.
func (s *Service) SubscriptionUser(token string) (auth.User, error) {
s.logger.Println("W! using noauth auth backend. Faked authentication for subscription user token")
return auth.NewUser("subscription-user", nil, true, nil), nil
}
func (s *Service) GrantSubscriptionAccess(token, db, rp string) error {
return nil
}
func (s *Service) ListSubscriptionTokens() ([]string, error) {
return nil, nil
}
func (s *Service) RevokeSubscriptionAccess(token string) error {
return nil
}