package
1.0.5
Repository: https://github.com/hyperledger-labs/cckit.git
Documentation: pkg.go.dev

# README

Owner - access control hyperledger fabric chaincode extension

In many cases during chaincode instantiating we need to define permissions for chaincode functions - "who is allowed to do this thing", incredibly important in the world of smart contracts, but in many examples access control implemented at the application level but not at the blockchain layer.

The most common and basic form of access control is the concept of ownership: there's one or more accounts (in case of Hyperledger Fabric chaincode model - combination of MSP and certificate) that is the owners and can do administrative tasks on contracts. This approach is perfectly reasonable for contracts that only have a single administrative user.

CCKit provides owner extension for implementing ownership and access control in Hyperledger Fabric chaincodes.

Owner extension implemented in two version:

  1. As chaincode handlers
  2. As service, that can be embedded in chaincode, using chaincode-as-service mode

# Functions

No description provided by the author
Get returns current chaincode owner identity.Entry Service implementation recommended, see chaincode_owner.proto.
IdentityEntryFromState returns identity.Entry with chaincode owner certificate Service implementation recommended, see chaincode_owner.proto.
Insert information about owner to chaincode state.
InvokeSetFromArgs gets owner data from args[0] (Msp Id) and arg[1] (cert).
InvokeSetFromCreator sets tx creator as chaincode owner, if owner not previously set.
IsInvoker checks than tx creator is chain code owner Service implementation recommended, see chaincode_owner.proto.
IsInvokerOr checks tx creator and compares with owner of another identity Service implementation recommended, see chaincode_owner.proto.
No description provided by the author
IsTxCreator returns error if owner identity (msp_id + certificate) did not match tx creator identity Service implementation recommended, see chaincode_owner.proto.
No description provided by the author
NewChaincodeOwnerServiceGateway creates gateway to access chaincode method via chaincode service.
No description provided by the author
No description provided by the author
Only allow access from chain code owner.
Query returns raw data (serialized Grant) of current chain code owner.
RegisterChaincodeOwnerServiceChaincode registers service methods as chaincode router handlers.
RegisterChaincodeOwnerServiceHandler registers the http handlers for service ChaincodeOwnerService to "mux".
RegisterChaincodeOwnerServiceHandlerClient registers the http handlers for service ChaincodeOwnerService to "mux".
RegisterChaincodeOwnerServiceHandlerFromEndpoint is same as RegisterChaincodeOwnerServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
RegisterChaincodeOwnerServiceHandlerServer registers the http handlers for service ChaincodeOwnerService to "mux".
No description provided by the author
SetFromArgs set owner from first args.
SetFromCreator sets chain code owner from stub creator Service implementation recommended, see chaincode_owner.proto.
No description provided by the author

# Constants

ChaincodeOwnerServiceChaincode method names.
ChaincodeOwnerServiceChaincode method names.
ChaincodeOwnerServiceChaincode method names.
ChaincodeOwnerServiceChaincode method names.
ChaincodeOwnerServiceChaincode method names.
ChaincodeOwnerServiceChaincode method names.
ChaincodeOwnerServiceChaincode method names.
ChaincodeOwnerServiceChaincodeMethodPrefix allows to use multiple services with same method names in one chaincode.
OwnerStateKey key used to store owner grant struct in chain code state "handler" part of owner extension supports only one owner "service" part of owner extension supports multiple owners.
No description provided by the author

# Variables

go:embed chaincode_owner.swagger.json.
No description provided by the author
No description provided by the author
ErrOwnerAlreadySet owner already set.
ErrOwnerNotProvided occurs when providing owner identity in init arguments.
ErrOwnerOnly error occurs when trying to invoke chaincode func protected by onlyOwner middleware (modifier).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

State: information stored in chaincode state about chaincode owner.
Event: new chaincode owner registered.
Event: chaincode owner deleted`.
List: Chaincode owners.
No description provided by the author
gateway implementation gateway can be used as kind of SDK, GRPC or REST server ( via grpc-gateway or clay ).
Event: new chaincode owner registered.
Request: register owner.
Id: owner identifier.
UnimplementedChaincodeOwnerServiceServer can be embedded to have forward compatible implementations.
Request: update owner certificate.

# Interfaces

ChaincodeOwnerServiceChaincode chaincode methods interface.
ChaincodeOwnerServiceClient is the client API for ChaincodeOwnerService service.
ChaincodeOwnerServiceServer is the server API for ChaincodeOwnerService service.