fablo icon indicating copy to clipboard operation
fablo copied to clipboard

User initialization

Open Nova38 opened this issue 11 months ago • 9 comments

Would it be possible to support creating users via the schema document. This would allow for streamlined setup of multi user environments, in addition to potentially useful for the snapshot feature in testing.

Nova38 avatar Mar 14 '24 01:03 Nova38

What do you mean by schema document?

Currently when you create a snapshot of the network in Fablo, it also keeps all CA user accounts. You just need to create them upfront.

dzikowski avatar Mar 15 '24 21:03 dzikowski

Ah okay that is helpful. The schema i was refering to is the json schema for the config file (https://github.com/hyperledger-labs/fablo/releases/download/1.2.1-unstable.0/schema.json)

My main thought was to extend the config file to include declartive user creation.

The values bellow i used the hlf bevel operator cmd as a refrence (https://github.com/hyperledger/bevel-operator-fabric?tab=readme-ov-file#register-and-enrolling-org1msp-identity)

kubectl hlf ca register --name=org1-ca --namespace=default --user=admin --secret=adminpw \
    --type=admin --enroll-id enroll --enroll-secret=enrollpw --mspid=Org1MSP
{
  "organization": {
    "name": "Org1",
    "domain": "org1.example.com"
  },
  "peer": {
    "instances": 2,
    "db": "LevelDb"
  },
  "ca":{ 
    "enrollId": "enroll",
    "enrollSecret": "enrollpw",
    "users": [
      {
        "name": "admin",
        "type": "admin",
        "secret": "adminpw"
      }
    ]
  }
}

Nova38 avatar Mar 15 '24 23:03 Nova38

I see. That would be useful. I suppose it involves two things:

  1. Adding relevant fields to config class (src/types/FabloConfigJson.ts) and config extended class (src/types/FabloConfigExtended.ts), and changing hardcoded values here: setup-docker/templates/fabric-docker/.env
  2. Register users, by calling CA server CLI or endpoint somewhere here (additional function?): setup-docker/templates/fabric-docker/commands-generated.sh.

dzikowski avatar Mar 16 '24 07:03 dzikowski

Awesome, when I get a chance this week/next I will take a look and put together a pull request

Nova38 avatar Mar 20 '24 05:03 Nova38

Do you mind if I include the code needed to also generate a network configuration file for hyperledger caliper as with the users generated it should be simple to populate the needed paths in the config file for all the given users.

https://hyperledger.github.io/caliper/v0.5.0/fabric-tutorial/tutorials-fabric-existing/#create-a-template-network-configuration-file

That would also partially address issue #298 298

Or would it be better to do that in another pull request if there is interest in it?

Nova38 avatar Mar 27 '24 02:03 Nova38

Please do it in a way that is more convenient for you. We'll be more than happy to have Caliper onboard. Thanks!

dzikowski avatar Mar 27 '24 05:03 dzikowski

It looks like the cli (fabric-tools) container doesn't have the fabric-ca-client exe. Should I download it dynamically, based on the fabric version, and then put it in the /workspaces/fablo/fablo-target/fabric-docker/scripts/cli folder that is mounted by the fabric-ci-box? Or is there a better place i should put it?

Nova38 avatar Mar 30 '24 00:03 Nova38

Yeah, I think this is a good approach, since we want to deprecate fabric-tools anyway (https://github.com/hyperledger-labs/fablo/issues/245). It's also deprecated in Hyperledger Fabric.

Have a look at this PR: https://github.com/hyperledger-labs/fablo/pull/316. It seems there was an effort towards downloading binaries, but I'm not sure why it's not merged. I guess it was just not required at that time. (@gzhk do you remember?).

Anyway, I think you can reuse some code from https://github.com/hyperledger-labs/fablo/pull/316 if you find it useful. And yes, scripts/cli path sounds good.

dzikowski avatar Mar 30 '24 08:03 dzikowski

Hi @Nova38 how is it going? Do you need some help with this issue?

dzikowski avatar May 07 '24 13:05 dzikowski