-
Notifications
You must be signed in to change notification settings - Fork 1
/
rbac.go
47 lines (38 loc) · 1.29 KB
/
rbac.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
package mock
import (
"context"
"github.com/resonatecoop/user-api-template/model"
)
// RBAC Mock
type RBAC struct {
EnforceRoleFn func(context.Context, model.AccessRole) bool
EnforceUserFn func(context.Context, int64) bool
EnforceTenantFn func(context.Context, int32) bool
EnforceTenantAdminFn func(context.Context, int32) bool
IsLowerRoleFn func(context.Context, model.AccessRole) bool
EnforceTenantAndRoleFn func(context.Context, model.AccessRole, int32) bool
}
// EnforceRole mock
func (a *RBAC) EnforceRole(c context.Context, role model.AccessRole) bool {
return a.EnforceRoleFn(c, role)
}
// EnforceUser mock
func (a *RBAC) EnforceUser(c context.Context, id int64) bool {
return a.EnforceUserFn(c, id)
}
// EnforceTenant mock
func (a *RBAC) EnforceTenant(c context.Context, id int32) bool {
return a.EnforceTenantFn(c, id)
}
// EnforceTenantAdmin mock
func (a *RBAC) EnforceTenantAdmin(c context.Context, id int32) bool {
return a.EnforceTenantAdminFn(c, id)
}
// EnforceTenantAndRole mock
func (a *RBAC) EnforceTenantAndRole(c context.Context, role model.AccessRole, id int32) bool {
return a.EnforceTenantAndRoleFn(c, role, id)
}
// IsLowerRole mock
func (a *RBAC) IsLowerRole(c context.Context, role model.AccessRole) bool {
return a.IsLowerRoleFn(c, role)
}