The enroll
code of fabcar is the enroll
of node-sdk.
In other words, they are the same.
const secret = await ca.register({
affiliation: 'org1.department1',
enrollmentID: 'appUser',
role: 'client'
}, adminUser);
const enrollment = await ca.enroll({
enrollmentID: 'appUser',
enrollmentSecret: secret
});
First, let's talk about fabric's SDK.
In general, in order to query/invoke chaincode on the fabric SDK, you need to obtain fabric client authority.
Suppose you register a specific user UUID as a Client of Fabric and call the chaincode through that Client.
In this case, the order you should perform is as follows.
- enroll admin-client to
Fabric-CA
- register user-client by admin-client to
Fabric-CA
- chaincode invoke by admin-client or user-client to
Fabric-Network(peers, orderers)
step 1, when Fabric-CA
is first operated, the administrator ID and password can be specified through specified parameters. Based on the specified ID and password, a client key/certificate with admin authority is issued from Fabric-CA
and stored.
(Fabric-CA
is recommended to be operated in an organizational unit, and client authority is organization dependent.)
step 2, a new user can be registered through the admin-client key/certificate. Probably you would register
the UUID as enrollmentID
.
When the registration process is finished, the user-client's key/certificate is issued by enrolling in Fabric-CA, and it is stored.
step 3, the chaincode is query/invoke through the stored admin-client/user-client key/certificate. Of course, it can be performed only if the client is authorized, and this is defined in the genesis block of the channel in the blockchain network (that is, it must be set in the configtxgen
process)
Overall, if you look at the scenario, you can see the two processes divided.
- In case of separate authentication server
- Build a new database(for off-chain).
- When registering as a member, the user's information(UUID, password ...) is stored in the database
- going through the fabric user-client registration process, the key and certificate are stored in the file system or database.
- When logging in, based on the newly established database, authentication is performed.
- When the chaincode of the fabric network is called while the user's validity is verified according to the authentication procedure, it operates based on the mapped key and certificate.
- When using an organization as an authentication server within Hyperledger Fabric
- User information is stored in the blockchain through
PDC(Private Data Collection)
provided by Fabric.
PDC
is an off-chain technology, and only predefined organizations share data.
- Through this function, validity of data can be performed by all organizations participating in the channel, but only organizations with permission can view/edit the actual sensitive information.
- In the end, the process and procedure are the same, but all resources can be managed on the blockchain.
(Like all technologies, they have pros and cons, and trade-offs need to be taken care of.)
[NOTE]
If you are going to query/invoke the chaincode of the fabric network, fabric-client
privileges are essential.
Of course, you can do some tricks.
for example)
- register admin-client on the server.
- After that, it operates the same as the existing authentication server/resource server.
- If the chaincode of Fabric Network is called, and it is valid by the existing authentication server, the chaincode is executed through the admin-client authority issued in advance.
- This does not require a separate user-client registration/management procedure.
However, the authority on the blockchain is all dependent on external certification authorities.