-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules_test.go
More file actions
42 lines (36 loc) · 948 Bytes
/
rules_test.go
File metadata and controls
42 lines (36 loc) · 948 Bytes
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
package rbac_test
import "github.com/stickypixel/hyperledger/rbac"
func allow(userID string, userRoles []string) rbac.QueryRule {
return rbac.QueryRule{Allow: true}
}
func disallow(userID string, userRoles []string) rbac.QueryRule {
return rbac.QueryRule{Allow: false}
}
func owner(userID string, userRoles []string) rbac.QueryRule {
return rbac.QueryRule{
Allow: true,
SelectorAppend: rbac.CDBSelector{
"createdBy": userID,
},
}
}
func filterFields(userID string, userRoles []string) rbac.QueryRule {
return rbac.QueryRule{
Allow: true,
FieldFilter: []string{"createdBy", "created"},
}
}
func inTransfer(userID string, userRoles []string) rbac.QueryRule {
return rbac.QueryRule{
Allow: true,
SelectorAppend: rbac.CDBSelector{
"$or": []rbac.CDBSelector{
{"createdBy": userID},
{"asset.from": userID},
{"asset.to": userID},
{"payment.from": userID},
{"payment.to": userID},
},
},
}
}