Hands-On Blockchain with Hyperledger
上QQ阅读APP看书,第一时间看更新

Registering a user

These steps are informational only and cannot be executed. For more information you can refer to the GitHub repository https://github.com/HyperledgerHandsOn/trade-finance-logistics/blob/master/chaincode/abac.md 

Let's now register a user with a custom attribute named importer and the value true. Note that the value of the attribute can be of any type and is not limited to Boolean values, as shown in the following snippet:

fabric-ca-client register --id.name user1 --id.secret pwd1 --id.type user --id.affiliation ImporterOrgMSP --id.attrs 'importer=true:ecert'

The previous snippet shows us the command line when registering a user with the attribute importer=true. Note that the values of id.secret and other arguments depend on the Fabric CA configuration.

The preceding command can also define multiple default attributes at once, such as: --id.attrs and importer=true:ecert,email=user1@gmail.com.

The following table contains the default attributes used during user registration:

If any of the previous attributes are needed in ecert, they must be first defined in the user registration command. For example, the following command registers user1 with the attribute hf.Affiliation=ImporterOrgMSP, which will be copied into ecert by default:

fabric-ca-client register --id.name user1 --id.secret pwd1 --id.type user --id.affiliation ImporterOrgMSP --id.attrs 'importer=true:ecert,hf.Affiliation=ImporterOrgMSP:ecert'