-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
48 lines (37 loc) · 1.57 KB
/
types.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
package rbac
import (
"github.com/hyperledger/fabric-chaincode-go/shim"
)
// If necessary, a method could be added to the empty interfaces to create more defined interfaces,
// which must be implemented by the consuming application's types.
// QueryRule describes a rule object.
type QueryRule struct {
Allow bool
FieldFilter []string
SelectorAppend CDBSelector
}
// QueryRuleFunc describes the signature of a rule callback function.
type QueryRuleFunc func(userID string, userRoles []string) QueryRule
// QueryPermissions maps Resources to QueryRuleFuncs.
type QueryPermissions map[string]QueryRuleFunc
// ContractFunc describes the signature of a chaincode ContractFunc.
type ContractFunc func(stub shim.ChaincodeStubInterface, args []string, auth AuthServiceInterface) ([]byte, error)
// ContractPermissions is the base permissions for contract invocation.
type ContractPermissions map[string]bool
// Permissions describes the types of permissions the RolePermissions can have.
type Permissions struct {
ContractPermissions
QueryPermissions
}
// RolePermissions maps a roles to Permissions.
type RolePermissions map[string]Permissions
// CDBSelector describes a CouchDB selector.
type CDBSelector map[string]interface{}
// CDBQuery describes a CouchDB query.
type CDBQuery struct {
Selector CDBSelector `json:"selector,omitempty"`
Limit uint `json:"limit,omitempty"`
Skip uint `json:"skip,omitempty"`
Fields []string `json:"fields,omitempty"`
Sort map[string]interface{} `json:"sort,omitempty"`
}