Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command to produce key and delegation for CI #154

Open
olizilla opened this issue Jan 10, 2024 · 4 comments
Open

Command to produce key and delegation for CI #154

olizilla opened this issue Jan 10, 2024 · 4 comments
Assignees

Comments

@olizilla
Copy link
Contributor

olizilla commented Jan 10, 2024

There are a few too many steps to setting up a delegation for an ephemeral environment.

What if we wrap it up as single command to create a key and delegation, and upload the delegation to w3s.

$ w3 delegation create --ci

signing key # 🔐 secret ************************************************************
# hit enter to reveal

signing key # 🔐 secret MgCZ3QPOHYno7UTitT7ZX7rKj2z/hUDtFqnQt7kzDs7G0NO0BE4YA4HL9o1QveL+ulIyypVHrKVntlFcP0Tix0crdNGI=
# keep it safe. it wont' be shown again.
# set it as W3_PRINCIPAL in the env in your ephemeral environment.
# hit enter to continue

delegation url # 🌍 public
https://bagb...ipfs.w3s.link
# permits the signing key to store/add and upload/add to web3.storage
# copy the url and provide it as a param to `w3 up`
# done!

then in an ephemeral environment like CI we let folks pass in all the state to the command

# set the signing key in env
$ W3_PRINCIPAL=**** # MgCZ3QPOHY...

# pass in delegation to use for the upload
$ w3 up --proof https://bagb...ipfs.w3s.link ./my/cool/site
⁂ uploaded 10 files

w3cli already lets us set the signing key via the W3_PRINCIPAL env var, the proposal is to allow users to provide a --proof flag with a url to a delegation to use for this operation.

This is how the new golang cli works today, and we could use that in the ephemeral env, which would make it easier for folks in environments where they dont want to or cant install the latest version of nodejs

note: passing it as a url implies it the command should fetch the delegation, and use the space DID that is specified in the delegation for the current operation.

how this works today

you have to pick out the did from the key generation, and create a delegation for it with the right capabilities, and then basee64 the car bytes so they survive being passed around as an string env var...

# make the keypair by running a commnad `ucan-key` from npm
$ npx ucan-key ed
# did:key:z6MkuQ2oEKUZzkKmWp3WWUi3WA7AMB9nTqQHz3n7ZqVfYjMf
MgCaQHJP9UXljiYf3q0ndDjrj/9kvJ3nLc2v1c0yS80Gf5O0B3guVFXZh3i4/VvtHUJpAfIByon/Icqa7cjASbybfSU4=

# create the delegation, use the did from above.
$ w3 delegation create -c 'store/add' -c 'upload/add' \ did:key:z6MkuQ2oEKUZzkKmWp3WWUi3WA7AMB9nTqQHz3n7ZqVfYjMf | base64
# long screed of base64 encoded CAR bytes to copy anb paste

# copy the space did
$ w3 space info
      DID: did:key:z6MkgAmfxiYjZFLmkGMCJ3xVNBWMZtyX5pCTzBQUJt2Xx2Vn
Providers: did:web:web3.storage

on the ci side, you have to write custom code (!?) or do something like this (untested conjecture, ymmv)

# set the signing key in env
$ W3_PRINCIPAL=**** # MgCZ3QPOHY...
$ W3_PROOF=**** # long screed of base64 encoded CAR bytes

# turn the base64 string into a file
$ echo "$W3_PROOF"| base64 --decode > proof.ucan

# import the delegation (and set it as the current space?)
$ w3 space add ./proof.ucan

$ w3 up ./my/cool/site

other options considered

What's not being proposed?

coupons

w3cli allows a user to create a coupon for another user. This allows the recipient to provision a space and have the coupon creator be pay the bill for that space.

In the case of a CI environment you want to define the space for the robot to add things to rather than have it create a new space each time.

w3 coupon create did:... - That can be used to create delegation and pack it as a redeemable coupon.
#123

w3 space provision --coupon https://gozala.io/coupon - That can be used to provision space with pre-arranged coupon

support base64 encoded proofs

Explored in #122 but i don't love it.

the string should probably be multibase encoded rather than raw base64. working with an ipfs url for the delegation seems nicer than a long base encoded string.

@olizilla
Copy link
Contributor Author

I want to streamline this process now so I can package it up as the new version of the add-to-web3 github action. With this the action would just be a single call to w3cli (or the go version) and some good docs and defaults.

@olizilla
Copy link
Contributor Author

This could be simpler and just show you the signing key, but the proposal uses the w3 space create flow as the template. note: that flow uses mnemonic words, but we dont yet support those as the value for the W3_PRINCIPAL env var, so we dont do that here

...which is intersesting, and maybe we shoud be consistent about that and support setting the principle from a mnemonic.

...but also it seems like the space recovery command that would import from mnemonic is missing in w3cli today! w3 can space recover is listed in the readme but it's not exposed as a command.

@olizilla olizilla changed the title Command to produce ephemeral delegation for CI Command to produce key and delegation for CI Jan 10, 2024
@alanshaw
Copy link
Member

As discussed:

  • I'd have a separate command to generate a key
  • Store/retrieve on IPFS feels weird to me
  • Would be beneficial for w3 delegation create to have --base64 option to output as (multibase encoded) base64
  • Would be beneficial for w3 up to have a --proof option that can take a base64 encoded proof or file path (which would nicely echo go-w3up CLI)
  • Sugar command is great, but I'd maybe have a separate command for it (rather than a --ci option to w3 delegation create) since the output is very different when passed

@olizilla olizilla self-assigned this Jan 10, 2024
olizilla added a commit that referenced this issue Jan 10, 2024
Print a new key pair. Does not change your current signing key.

Bring the feature from [`ucan-key`](https://github.com/olizilla/ucan-key) into w3cli

see: #154 (comment)

License: MIT
Signed-off-by: Oli Evans <[email protected]>
@olizilla
Copy link
Contributor Author

@Gozala plz may i have your thoughts on this too?

alanshaw added a commit that referenced this issue Jan 15, 2024
Print a new key pair. Does not change your current signing key.

Bring the feature from
[`ucan-key`](https://github.com/olizilla/ucan-key) into w3cli

```shell
$ w3 key create
# did:key:z6Mkne1JnNWCvUgxsdo552FW8jRN78uxbpCnBmDiPmf1koYc
MgCZ5ftHm9e0FnNtFXA2sMZgcf97GO4vTaybGEfkBp/KR5+0BeZ44TKEOwUjbLqvFFs2hpFxD++IAEEL+3ySROyDsSRk=

$ w3 key create --json | jq
{
  "did": "did:key:z6Mkt7urpgJKK38cEyB1uMGBzfdn6sZN2daB5pr75DZbgahZ",
  "key": "MgCYj0pKJn5uf+4yr2DApB8idYtDY+9yhEYH64Po0uaj+R+0Byw7B8cSYrO4//5PqgWodYq8PMI/fSWZ1xdvdw15bmAw="
}
```

see:
#154 (comment)

License: MIT

---------

Signed-off-by: Oli Evans <[email protected]>
Co-authored-by: Alan Shaw <[email protected]>
olizilla added a commit that referenced this issue Jan 15, 2024
…ed proof>`

**export** a delegation as base64 encoded identity CID with `w3 delegation create --stringify`

```shell
$ w3 delegation create did:key:z6MkviAsUfBwegmB57byQ7SZTFtX4jN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LGcV6/UwthdmUwLjkuMWNhdHSComNjYW5pc3RvcmUvYWRkZHdpdGh4OGRpZDprZXk6ejZNa2hmelR3WkoyOGFSb2JDcDc2dVhScXpzakg2R051MThXRndNdW1rQUY1b2pXomNjYW5qdXBsb2FkL2FkZGR3aXRoeDhkaWQ6a2V5Ono2TWtoZnpUd1pKMjhhUm9iQ3A3NnVYUnF6c2pINkdOdTE4V0Z3TXVta0FGNW9qV2NhdWRYIu0B8YzaLs8NDe7oZt6rlpsW6iMh8XsoXZLvkHPqtftYRXZjZXhw9mNmY3SBoWVzcGFjZaFkbmFtZWV0b290c2Npc3NYIu0B6G/tfSQzFAbPrtXuuOrzdjC6L0FFwO8SXhbNkx1HG/pjcHJmgtgqWCUAAXESIC+8P5gFjzlfFrfwdMoHWjiPttP2RvKV/uWM2eV/VOMu2CpYJQABcRIgL7w/mAWPOV8Wt/B0ygdaOI+20/ZG8pX+5YzZ5X9U4y4
```

...yes, what if we put the CAR _in_ the CID! That way we can detect when the input has been truncted, and the screed is self describing... you can paste it into cid.ipfs.tech and it'll tell you it's CAR flavour identity hashed bytes!

**import** a space from a stringified proof

```shell
$ w3 space $PROOF
did:key:z6MkhfzTwZJ28aRobCp76uXRqzsjH6GNu18WFwMumkAF5ojW
```

see: #154 (comment)

License: MIT
Signed-off-by: Oli Evans <[email protected]>
olizilla added a commit that referenced this issue Jan 17, 2024
**export** a delegation as base64 encoded identity CID with `w3
delegation create --base64`

```shell
$ w3 delegation create did:key:z6MkviAsUfBwegmB57byQ7SZTFtX4jNjo315EvgurjWYoTRX --can 'store/add' --can 'upload/add' --base64
mAYIEAO0OEaJlcm9vdHOAZ3ZlcnNpb24BvQUBcRIgL7w/mAWPOV8Wt/B0ygdaOI+20/ZG8pX+5YzZ5X9U4y6oYXNYRO2hA0CbPDJlxyrorHHdNAUnRUDA4xU7KHgHHstkM8tBxq+6KaQP5xLCknOh9TjkR0S0yuK/fiFxKwRDUHfECFEWQn4DYXZlMC45LjFjYXR0hqJj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RXZjZXhw9mNmY3SBoWVzcGFjZaFkbmFtZWV0b290c2Npc3NYIu0B6G/tfSQzFAbPrtXuuOrzdjC6L0FFwO8SXhbNkx1HG/pjcHJmgtgqWCUAAXESIC+8P5gFjzlfFrfwdMoHWjiPttP2RvKV/uWM2eV/VOMu2CpYJQABcRIgL7w/mAWPOV8Wt/B0ygdaOI+20/ZG8pX+5YzZ5X9U4y4
```

...yes, what if we put the CAR _in_ the CID! That way we can detect when
the input has been truncted, and the screed is self describing... you
can paste it into
[cid.ipfs.tech](https://cid.ipfs.tech/#mAYIEAO0OEaJlcm9vdHOAZ3ZlcnNpb24BvQUBcRIgL7w/mAWPOV8Wt/B0ygdaOI+20/ZG8pX+5YzZ5X9U4y6oYXNYRO2hA0CbPDJlxyrorHHdNAUnRUDA4xU7KHgHHstkM8tBxq+6KaQP5xLCknOh9TjkR0S0yuK/fiFxKwRDUHfECFEWQn4DYXZlMC45LjFjYXR0hqJjY2FuZ3NwYWNlLypkd2l0aHg4ZGlkOmtleTp6Nk1raGZ6VHdaSjI4YVJvYkNwNzZ1WFJxenNqSDZHTnUxOFdGd011bWtBRjVvaleiY2NhbmdzdG9yZS8qZHdpdGh4OGRpZDprZXk6ejZNa2hmelR3WkoyOGFSb2JDcDc2dVhScXpzakg2R051MThXRndNdW1rQUY1b2pXomNjYW5odXBsb2FkLypkd2l0aHg4ZGlkOmtleTp6Nk1raGZ6VHdaSjI4YVJvYkNwNzZ1WFJxenNqSDZHTnUxOFdGd011bWtBRjVvaleiY2NhbmhhY2Nlc3MvKmR3aXRoeDhkaWQ6a2V5Ono2TWtoZnpUd1pKMjhhUm9iQ3A3NnVYUnF6c2pINkdOdTE4V0Z3TXVta0FGNW9qV6JjY2FuamZpbGVjb2luLypkd2l0aHg4ZGlkOmtleTp6Nk1raGZ6VHdaSjI4YVJvYkNwNzZ1WFJxenNqSDZHTnUxOFdGd011bWtBRjVvaleiY2Nhbmd1c2FnZS8qZHdpdGh4OGRpZDprZXk6ejZNa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Y2WhZG5hbWVldG9vdHNjaXNzWCLtAS/V/qeFMs9Oc0h9KJfE2D16cFPRJYzUaNTtfLmG1pb5Y3ByZoDbAwFxEiB9iHpD1ttdKEQCvBZ8jJBD7Wqw1abOtYwNCKAKYALXMqhhc1hE7aEDQJ7U8I+a4Au/eb10r9T89weG/Nl2jccEUXHs8wq+i2tU0Iaik8KaKvovDqqE57JU8ZoY0JAzOBW7cMLGcV6/UwthdmUwLjkuMWNhdHSComNjYW5pc3RvcmUvYWRkZHdpdGh4OGRpZDprZXk6ejZNa2hmelR3WkoyOGFSb2JDcDc2dVhScXpzakg2R051MThXRndNdW1rQUY1b2pXomNjYW5qdXBsb2FkL2FkZGR3aXRoeDhkaWQ6a2V5Ono2TWtoZnpUd1pKMjhhUm9iQ3A3NnVYUnF6c2pINkdOdTE4V0Z3TXVta0FGNW9qV2NhdWRYIu0B8YzaLs8NDe7oZt6rlpsW6iMh8XsoXZLvkHPqtftYRXZjZXhw9mNmY3SBoWVzcGFjZaFkbmFtZWV0b290c2Npc3NYIu0B6G/tfSQzFAbPrtXuuOrzdjC6L0FFwO8SXhbNkx1HG/pjcHJmgtgqWCUAAXESIC+8P5gFjzlfFrfwdMoHWjiPttP2RvKV/uWM2eV/VOMu2CpYJQABcRIgL7w/mAWPOV8Wt/B0ygdaOI+20/ZG8pX+5YzZ5X9U4y4)
and it'll tell you it's CAR flavour identity hashed bytes!

**import** a space from a stringified proof

```shell
$ w3 space add $PROOF
did:key:z6MkhfzTwZJ28aRobCp76uXRqzsjH6GNu18WFwMumkAF5ojW
```

see:
#154 (comment)

## Usage

**on your machine**

- with `@web3-storage/w3cli` installed.
- Set the space you want CI to upload to as the current space

```shell
# create a key for ci
$ w3 key create --json > ci.json

# create a proof for that key. copy paste it to env var in CI
$ w3 delegation create $(jq -r .did ci.json) -c 'store/add' -c 'upload/add' --base64
mA...
```

**in CI**

- install `@web3-storage/w3cli`. No need to login, we pass it the proof
to use.
- copy paste the key we generated above `(jq -r .key ci.json)` as a
secret in your ci workflow. _KEEP IT SECRET!_
- copy paste the proof we generated above as a variable or secret in
your ci workflow. _it's ok to share this, only the holder of the secret
key can use it._

```shell
# set key (jq -r .key ci.json) in env so w3cli uses it instead of generating one
$ W3_PRINCIPAL=${{ secrets.w3key }}

# import the space from the stringified proof
$ w3 space add ${{ vars.w3proof }}

# upload yer stuff
$ w3 upload ./my/cool/stuff
```


License: MIT

---------

Signed-off-by: Oli Evans <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants