Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions common/capabilities/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ func (ap *ApplicationProvider) Type() string {
return applicationTypeName
}

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

// ForbidDuplicateTXIdInBlock specifies whether two transactions with the same TXId are permitted
Expand Down
4 changes: 4 additions & 0 deletions common/capabilities/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
func TestApplicationV10(t *testing.T) {
ap := NewApplicationProvider(map[string]*cb.Capability{})
require.NoError(t, ap.Supported())
// ACLs are always enabled in Fabric-X, regardless of capability version
require.True(t, ap.ACLs())
}

func TestApplicationV11(t *testing.T) {
Expand All @@ -25,6 +27,8 @@ func TestApplicationV11(t *testing.T) {
require.NoError(t, ap.Supported())
require.True(t, ap.ForbidDuplicateTXIdInBlock())
require.True(t, ap.V1_1Validation())
// ACLs are always enabled in Fabric-X, regardless of capability version
require.True(t, ap.ACLs())
}

func TestApplicationV12(t *testing.T) {
Expand Down
6 changes: 0 additions & 6 deletions common/channelconfig/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ func NewApplicationConfig(appGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler)
return nil, errors.Wrap(err, "failed to deserialize values")
}

if !ac.Capabilities().ACLs() {
if _, ok := appGroup.Values[ACLsKey]; ok {
return nil, errors.New("ACLs may not be specified without the required capability")
}
}

var err error
for orgName, orgGroup := range appGroup.Groups {
ac.applicationOrgs[orgName], err = NewApplicationOrgConfig(orgName, orgGroup, mspConfig)
Expand Down
8 changes: 6 additions & 2 deletions common/channelconfig/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import (
)

func TestApplicationInterface(t *testing.T) {
t.Parallel()
_ = Application((*ApplicationConfig)(nil))
}

func TestACL(t *testing.T) {
t.Parallel()
g := NewGomegaWithT(t)
cgt := &cb.ConfigGroup{
Values: map[string]*cb.ConfigValue{
Expand All @@ -41,15 +43,17 @@ func TestACL(t *testing.T) {
}

t.Run("Success", func(t *testing.T) {
t.Parallel()
cg := proto.Clone(cgt).(*cb.ConfigGroup)
_, err := NewApplicationConfig(proto.Clone(cg).(*cb.ConfigGroup), nil)
g.Expect(err).NotTo(HaveOccurred())
})

t.Run("MissingCapability", func(t *testing.T) {
t.Run("ACLsAllowedWithoutCapability", func(t *testing.T) {
t.Parallel()
cg := proto.Clone(cgt).(*cb.ConfigGroup)
delete(cg.Values, CapabilitiesKey)
_, err := NewApplicationConfig(cg, nil)
g.Expect(err).To(MatchError("ACLs may not be specified without the required capability"))
g.Expect(err).NotTo(HaveOccurred())
})
}
4 changes: 4 additions & 0 deletions core/aclmgmt/defaultaclprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
pb "github.com/hyperledger/fabric-protos-go-apiv2/peer"

"github.com/hyperledger/fabric-x-common/common/policies"
"github.com/hyperledger/fabric-x-common/core/aclmgmt/resources"
"github.com/hyperledger/fabric-x-common/core/policy"
"github.com/hyperledger/fabric-x-common/protoutil"
)
Expand Down Expand Up @@ -46,6 +47,9 @@ func newDefaultACLProvider(policyChecker policy.PolicyChecker) defaultACLProvide
cResourcePolicyMap: map[string]string{},
}

// Peer resources
d.cResourcePolicyMap[resources.Peer_Propose] = CHANNELWRITERS

return d
}

Expand Down
7 changes: 7 additions & 0 deletions core/aclmgmt/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ SPDX-License-Identifier: Apache-2.0

// Package resources contains resource names used in fabric for ACL checks.
package resources

const (
// Peer_Propose is the ACL resource for the peer Propose API.
// The underscore naming is intentional to preserve compatibility with
// downstream consumers (e.g., fabric-smart-client) that reference this constant.
Peer_Propose = "peer/Propose" //nolint:revive,staticcheck
)
Loading