policies

package
v0.0.0-...-94b13b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Path separator is used to separate policy names in paths
	PathSeparator = "/"

	// ChannelPrefix is used in the path of standard channel policy managers
	ChannelPrefix = "Channel"

	// ApplicationPrefix is used in the path of standard application policy paths
	ApplicationPrefix = "Application"

	// OrdererPrefix is used in the path of standard orderer policy paths
	OrdererPrefix = "Orderer"

	// ChannelReaders is the label for the channel's readers policy (encompassing both orderer and application readers)
	ChannelReaders = PathSeparator + ChannelPrefix + PathSeparator + "Readers"

	// ChannelWriters is the label for the channel's writers policy (encompassing both orderer and application writers)
	ChannelWriters = PathSeparator + ChannelPrefix + PathSeparator + "Writers"

	// ChannelApplicationReaders is the label for the channel's application readers policy
	ChannelApplicationReaders = PathSeparator + ChannelPrefix + PathSeparator + ApplicationPrefix + PathSeparator + "Readers"

	// ChannelApplicationWriters is the label for the channel's application writers policy
	ChannelApplicationWriters = PathSeparator + ChannelPrefix + PathSeparator + ApplicationPrefix + PathSeparator + "Writers"

	// ChannelApplicationAdmins is the label for the channel's application admin policy
	ChannelApplicationAdmins = PathSeparator + ChannelPrefix + PathSeparator + ApplicationPrefix + PathSeparator + "Admins"

	// BlockValidation is the label for the policy which should validate the block signatures for the channel
	BlockValidation = PathSeparator + ChannelPrefix + PathSeparator + OrdererPrefix + PathSeparator + "BlockValidation"
)

Variables

This section is empty.

Functions

func ImplicitMetaPolicyWithSubPolicy

func ImplicitMetaPolicyWithSubPolicy(subPolicyName string, rule cb.ImplicitMetaPolicy_Rule) *cb.ConfigPolicy

ImplicitMetaPolicyWithSubPolicy creates an implicitmeta policy

func TemplateImplicitMetaAllPolicy

func TemplateImplicitMetaAllPolicy(path []string, policyName string) *cb.ConfigGroup

TempateImplicitMetaAnyPolicy returns TemplateImplicitMetaPolicy with cb.ImplicitMetaPolicy_ALL as the rule

func TemplateImplicitMetaAnyPolicy

func TemplateImplicitMetaAnyPolicy(path []string, policyName string) *cb.ConfigGroup

TempateImplicitMetaAnyPolicy returns TemplateImplicitMetaPolicy with cb.ImplicitMetaPolicy_ANY as the rule

func TemplateImplicitMetaMajorityPolicy

func TemplateImplicitMetaMajorityPolicy(path []string, policyName string) *cb.ConfigGroup

TempateImplicitMetaAnyPolicy returns TemplateImplicitMetaPolicy with cb.ImplicitMetaPolicy_MAJORITY as the rule

func TemplateImplicitMetaPolicy

func TemplateImplicitMetaPolicy(path []string, policyName string, rule cb.ImplicitMetaPolicy_Rule) *cb.ConfigGroup

TemplateImplicitMetaPolicy creates a policy at the specified path with the given policyName It utilizes the policyName for the subPolicyName as well, as this is the standard usage pattern

func TemplateImplicitMetaPolicyWithSubPolicy

func TemplateImplicitMetaPolicyWithSubPolicy(path []string, policyName string, subPolicyName string, rule cb.ImplicitMetaPolicy_Rule) *cb.ConfigGroup

TemplateImplicitMetaPolicy creates a policy at the specified path with the given policyName and subPolicyName

Types

type ChannelPolicyManagerGetter

type ChannelPolicyManagerGetter interface {
	// Returns the policy manager associated to the passed channel
	// and true if it was the manager requested, or false if it is the default manager
	Manager(channelID string) (Manager, bool)
}

ChannelPolicyManagerGetter is a support interface to get access to the policy manager of a given channel

type Manager

type Manager interface {
	// GetPolicy returns a policy and true if it was the policy requested, or false if it is the default policy
	GetPolicy(id string) (Policy, bool)

	// Manager returns the sub-policy manager for a given path and whether it exists
	Manager(path []string) (Manager, bool)

	// Basepath returns the basePath the manager was instantiated with
	BasePath() string

	// Policies returns all policy names defined in the manager
	PolicyNames() []string
}

Manager is a read only subset of the policy ManagerImpl

type ManagerImpl

type ManagerImpl struct {

	// SuppressSanityLogMessages when set to true will prevent the sanity checking log
	// messages.  Useful for novel cases like channel templates
	SuppressSanityLogMessages bool
	// contains filtered or unexported fields
}

ManagerImpl is an implementation of Manager and configtx.ConfigHandler In general, it should only be referenced as an Impl for the configtx.ConfigManager

func NewManagerImpl

func NewManagerImpl(basePath string, providers map[int32]Provider) *ManagerImpl

NewManagerImpl creates a new ManagerImpl with the given CryptoHelper

func (*ManagerImpl) BasePath

func (pm *ManagerImpl) BasePath() string

Basepath returns the basePath the manager was instnatiated with

func (*ManagerImpl) BeginPolicyProposals

func (pm *ManagerImpl) BeginPolicyProposals(tx interface{}, groups []string) ([]Proposer, error)

BeginPolicies is used to start a new config proposal

func (*ManagerImpl) CommitProposals

func (pm *ManagerImpl) CommitProposals(tx interface{})

CommitProposals is used to commit a new config proposal

func (*ManagerImpl) GetPolicy

func (pm *ManagerImpl) GetPolicy(id string) (Policy, bool)

GetPolicy returns a policy and true if it was the policy requested, or false if it is the default reject policy

func (*ManagerImpl) Manager

func (pm *ManagerImpl) Manager(path []string) (Manager, bool)

Manager returns the sub-policy manager for a given path and whether it exists

func (*ManagerImpl) PolicyNames

func (pm *ManagerImpl) PolicyNames() []string

func (*ManagerImpl) PreCommit

func (pm *ManagerImpl) PreCommit(tx interface{}) error

PreCommit is currently a no-op for the policy manager and always returns nil

func (*ManagerImpl) ProposePolicy

func (pm *ManagerImpl) ProposePolicy(tx interface{}, key string, configPolicy *cb.ConfigPolicy) (proto.Message, error)

ProposePolicy takes key, path, and ConfigPolicy and registers it in the proposed PolicyManager, or errors It also returns the deserialized policy value for tracking and inspection at the invocation side.

func (*ManagerImpl) RollbackProposals

func (pm *ManagerImpl) RollbackProposals(tx interface{})

RollbackProposals is used to abandon a new config proposal

type Policy

type Policy interface {
	// Evaluate takes a set of SignedData and evaluates whether this set of signatures satisfies the policy
	Evaluate(signatureSet []*cb.SignedData) error
}

Policy is used to determine if a signature is valid

type Proposer

type Proposer interface {
	// BeginPolicyProposals starts a policy update transaction
	BeginPolicyProposals(tx interface{}, groups []string) ([]Proposer, error)

	// ProposePolicy createss a pending policy update from a ConfigPolicy and returns the deserialized
	// value of the Policy representation
	ProposePolicy(tx interface{}, name string, policy *cb.ConfigPolicy) (proto.Message, error)

	// RollbackProposals discards the pending policy updates
	RollbackProposals(tx interface{})

	// CommitProposals commits the pending policy updates
	CommitProposals(tx interface{})

	// PreCommit tests if a commit will apply
	PreCommit(tx interface{}) error
}

Proposer is the interface used by the configtx manager for policy management

type Provider

type Provider interface {
	// NewPolicy creates a new policy based on the policy bytes
	NewPolicy(data []byte) (Policy, proto.Message, error)
}

Provider provides the backing implementation of a policy

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL