@@ -25,6 +25,7 @@ import (
25
25
26
26
"errors"
27
27
28
+ "github.com/hyperledger/fabric/common/policies"
28
29
"github.com/hyperledger/fabric/common/util"
29
30
"github.com/hyperledger/fabric/core/chaincode"
30
31
"github.com/hyperledger/fabric/core/chaincode/shim"
@@ -55,27 +56,16 @@ func NewEndorserServer() pb.EndorserServer {
55
56
}
56
57
57
58
// checkACL checks that the supplied proposal complies
58
- // with the policies of the chain; for a system chaincode
59
- // we use the admins policy, whereas for normal chaincodes
60
- // we use the writers policy
59
+ // with the writers policy of the chain
61
60
func (* Endorser ) checkACL (signedProp * pb.SignedProposal , chdr * common.ChannelHeader , shdr * common.SignatureHeader , hdrext * pb.ChaincodeHeaderExtension ) error {
62
- /****** FAB-2457- we need to fix this right
63
61
// get policy manager to check ACLs
64
62
pm := peer .GetPolicyManager (chdr .ChannelId )
65
63
if pm == nil {
66
64
return fmt .Errorf ("No policy manager available for chain %s" , chdr .ChannelId )
67
65
}
68
66
69
67
// access the policy to use to validate this proposal
70
- var policyName string
71
- if syscc.IsSysCC(hdrext.ChaincodeId.Name) {
72
- // in the case of a system chaincode, we use the admin policy
73
- policyName = policies.ChannelApplicationAdmins
74
- } else {
75
- // in the case of a normal chaincode, we use the writers policy
76
- policyName = policies.ChannelApplicationWriters
77
- }
78
- policy, _ := pm.GetPolicy(policyName)
68
+ policy , _ := pm .GetPolicy (policies .ChannelApplicationWriters )
79
69
80
70
// evaluate that this proposal complies with the writers
81
71
err := policy .Evaluate (
@@ -86,11 +76,10 @@ func (*Endorser) checkACL(signedProp *pb.SignedProposal, chdr *common.ChannelHea
86
76
}})
87
77
if err != nil {
88
78
return fmt .Errorf ("The proposal does not comply with the %s for channel %s, error %s" ,
89
- policyName ,
79
+ policies . ChannelApplicationWriters ,
90
80
chdr .ChannelId ,
91
81
err )
92
82
}
93
- **********/
94
83
95
84
return nil
96
85
}
@@ -345,10 +334,13 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro
345
334
return nil , fmt .Errorf ("Duplicate transaction found [%s]. Creator [%x]. [%s]" , txid , shdr .Creator , err )
346
335
}
347
336
348
- // check ACL - we verify that this proposal
349
- // complies with the policy of the chain
350
- if err = e .checkACL (signedProp , chdr , shdr , hdrExt ); err != nil {
351
- return & pb.ProposalResponse {Response : & pb.Response {Status : 500 , Message : err .Error ()}}, err
337
+ // check ACL only for application chaincodes; ACLs
338
+ // for system chaincodes are checked elsewhere
339
+ if ! syscc .IsSysCC (hdrExt .ChaincodeId .Name ) {
340
+ // check that the proposal complies with the channel's writers
341
+ if err = e .checkACL (signedProp , chdr , shdr , hdrExt ); err != nil {
342
+ return & pb.ProposalResponse {Response : & pb.Response {Status : 500 , Message : err .Error ()}}, err
343
+ }
352
344
}
353
345
} else {
354
346
// chainless proposals do not/cannot affect ledger and cannot be submitted as transactions
0 commit comments