-
Notifications
You must be signed in to change notification settings - Fork 0
/
acls.go
39 lines (31 loc) · 1 KB
/
acls.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
/*
Copyright State Street Corp. 2018 All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package channelconfig
import (
pb "github.com/hyperledger/fabric/protos/peer"
)
// aclsProvider provides mappings for resource to policy names
type aclsProvider struct {
aclPolicyRefs map[string]string
}
func (ag *aclsProvider) PolicyRefForAPI(aclName string) string {
return ag.aclPolicyRefs[aclName]
}
// this translates policies to absolute paths if needed
func newAPIsProvider(acls map[string]*pb.APIResource) *aclsProvider {
aclPolicyRefs := make(map[string]string)
for key, acl := range acls {
// If the policy is fully qualified, ie to /Channel/Application/Readers leave it alone
// otherwise, make it fully qualified referring to /Channel/Application/policyName
if '/' != acl.PolicyRef[0] {
aclPolicyRefs[key] = "/" + ChannelGroupKey + "/" + ApplicationGroupKey + "/" + acl.PolicyRef
} else {
aclPolicyRefs[key] = acl.PolicyRef
}
}
return &aclsProvider{
aclPolicyRefs: aclPolicyRefs,
}
}