Skip to content

Commit 790e564

Browse files
committed
Restore Peer_Propose ACL resource and remove ACL capability gates
Commit c948ab2 removed all ACL resource constants and default policy mappings, but fabric-smart-client's fabricx membership service still depends on: - resources.Peer_Propose constant ("peer/Propose") - default ACL mapping Peer_Propose → CHANNELWRITERS - aclmgmt.ACLProvider / aclmgmt.NewACLProvider Without these, FSC fails to compile and CheckACL would hit "Unmapped policy" at runtime. Additionally, remove the capability gate that rejected ACLs when the application capability version was below V1_2. In Fabric-X, ACLs are always allowed regardless of capability version. Changes: - core/aclmgmt/resources/resources.go: restore Peer_Propose constant - core/aclmgmt/defaultaclprovider.go: restore Peer_Propose → CHANNELWRITERS mapping - common/capabilities/application.go: ACLs() always returns true - common/channelconfig/application.go: remove capability validation gate - Update tests for always-allowed ACLs Signed-off-by: Senthilnathan <cendhu@gmail.com>
1 parent c948ab2 commit 790e564

6 files changed

Lines changed: 18 additions & 10 deletions

File tree

common/capabilities/application.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ func (ap *ApplicationProvider) Type() string {
6969
return applicationTypeName
7070
}
7171

72-
// ACLs returns whether ACLs may be specified in the channel application config
72+
// ACLs returns whether ACLs may be specified in the channel application config.
73+
// In Fabric-X, ACLs are always allowed regardless of capability version.
7374
func (ap *ApplicationProvider) ACLs() bool {
74-
return ap.v12 || ap.v13 || ap.v142 || ap.v20 || ap.v25
75+
return true
7576
}
7677

7778
// ForbidDuplicateTXIdInBlock specifies whether two transactions with the same TXId are permitted

common/capabilities/application_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
func TestApplicationV10(t *testing.T) {
1717
ap := NewApplicationProvider(map[string]*cb.Capability{})
1818
require.NoError(t, ap.Supported())
19+
// ACLs are always enabled in Fabric-X, regardless of capability version
20+
require.True(t, ap.ACLs())
1921
}
2022

2123
func TestApplicationV11(t *testing.T) {
@@ -25,6 +27,8 @@ func TestApplicationV11(t *testing.T) {
2527
require.NoError(t, ap.Supported())
2628
require.True(t, ap.ForbidDuplicateTXIdInBlock())
2729
require.True(t, ap.V1_1Validation())
30+
// ACLs are always enabled in Fabric-X, regardless of capability version
31+
require.True(t, ap.ACLs())
2832
}
2933

3034
func TestApplicationV12(t *testing.T) {

common/channelconfig/application.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ func NewApplicationConfig(appGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler)
4545
return nil, errors.Wrap(err, "failed to deserialize values")
4646
}
4747

48-
if !ac.Capabilities().ACLs() {
49-
if _, ok := appGroup.Values[ACLsKey]; ok {
50-
return nil, errors.New("ACLs may not be specified without the required capability")
51-
}
52-
}
53-
5448
var err error
5549
for orgName, orgGroup := range appGroup.Groups {
5650
ac.applicationOrgs[orgName], err = NewApplicationOrgConfig(orgName, orgGroup, mspConfig)

common/channelconfig/application_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ func TestACL(t *testing.T) {
4646
g.Expect(err).NotTo(HaveOccurred())
4747
})
4848

49-
t.Run("MissingCapability", func(t *testing.T) {
49+
t.Run("ACLsAllowedWithoutCapability", func(t *testing.T) {
5050
cg := proto.Clone(cgt).(*cb.ConfigGroup)
5151
delete(cg.Values, CapabilitiesKey)
5252
_, err := NewApplicationConfig(cg, nil)
53-
g.Expect(err).To(MatchError("ACLs may not be specified without the required capability"))
53+
g.Expect(err).NotTo(HaveOccurred())
5454
})
5555
}

core/aclmgmt/defaultaclprovider.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
pb "github.com/hyperledger/fabric-protos-go-apiv2/peer"
1414

1515
"github.com/hyperledger/fabric-x-common/common/policies"
16+
"github.com/hyperledger/fabric-x-common/core/aclmgmt/resources"
1617
"github.com/hyperledger/fabric-x-common/core/policy"
1718
"github.com/hyperledger/fabric-x-common/protoutil"
1819
)
@@ -46,6 +47,9 @@ func newDefaultACLProvider(policyChecker policy.PolicyChecker) defaultACLProvide
4647
cResourcePolicyMap: map[string]string{},
4748
}
4849

50+
// Peer resources
51+
d.cResourcePolicyMap[resources.Peer_Propose] = CHANNELWRITERS
52+
4953
return d
5054
}
5155

core/aclmgmt/resources/resources.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ SPDX-License-Identifier: Apache-2.0
66

77
// Package resources contains resource names used in fabric for ACL checks.
88
package resources
9+
10+
const (
11+
// Peer resources
12+
Peer_Propose = "peer/Propose"
13+
)

0 commit comments

Comments
 (0)