-
Notifications
You must be signed in to change notification settings - Fork 245
/
noop.go
53 lines (42 loc) · 1.38 KB
/
noop.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
package rbac
type noOpService struct{}
// NewNoOpService is used to instantiated a noOpService for when rbac enabled=false.
func NewNoOpService() Service {
return &noOpService{}
}
// Enforce no-op enforcement. Allows everything.
func (n noOpService) Enforce(username, method, path string, params map[string]string) error {
// Allow all
return nil
}
// AddRole that errors since rbac is not enabled.
func (n noOpService) AddRole(role string, roleRules []RoleRule) error {
return nil
}
// DeleteRole that errors since rbac is not enabled.
func (n noOpService) DeleteRole(role string) error {
return nil
}
// GetAllRoles that returns nothing since rbac is not enabled.
func (n noOpService) GetAllRoles() []string {
return []string{}
}
// GetUserAttachedRoles that errors since rbac is not enabled.
func (n noOpService) GetUserAttachedRoles(username string) ([]string, error) {
return nil, nil
}
// GetRoleAttachedUsers that errors since rbac is not enabled.
func (n noOpService) GetRoleAttachedUsers(role string) ([]string, error) {
return nil, nil
}
// AttachRole that errors since rbac is not enabled.
func (n noOpService) AttachRole(username string, role string) error {
return nil
}
// DetachRole that errors since rbac is not enabled.
func (n noOpService) DetachRole(username string, role string) error {
return nil
}
func (n noOpService) DeleteUser(username string) error {
return nil
}