1 Star 0 Fork 0

peter/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
accesscontrol.go 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
Angelo De Caro 提交于 2018-08-08 21:56 +08:00 . [FAB-11524] Prover: Request Import
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package server
import (
"github.com/hyperledger/fabric/common/policies"
"github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/token"
"github.com/pkg/errors"
)
//go:generate counterfeiter -o mock/signed_data_policy_checker.go -fake-name SignedDataPolicyChecker . SignedDataPolicyChecker
type SignedDataPolicyChecker interface {
// CheckPolicyBySignedData checks that the provided signed data is valid with respect to
// specified policy for the specified channel.
CheckPolicyBySignedData(channelID, policyName string, sd []*common.SignedData) error
}
// PolicyBasedAccessControl implements token command access control functions.
type PolicyBasedAccessControl struct {
SignedDataPolicyChecker SignedDataPolicyChecker
}
func (ac *PolicyBasedAccessControl) Check(sc *token.SignedCommand, c *token.Command) error {
switch t := c.GetPayload().(type) {
case *token.Command_ImportRequest:
return ac.SignedDataPolicyChecker.CheckPolicyBySignedData(
c.Header.ChannelId,
policies.ChannelApplicationWriters,
[]*common.SignedData{{
Identity: c.Header.Creator,
Data: sc.Command,
Signature: sc.Signature,
}},
)
default:
return errors.Errorf("command type not recognized: %T", t)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/peter_code_git/fabric.git
git@gitee.com:peter_code_git/fabric.git
peter_code_git
fabric
fabric
v1.3.0

搜索帮助