From 168661133c7f162aa4c3c0308e422e9234553e0f Mon Sep 17 00:00:00 2001 From: wwwjim Date: Tue, 10 Dec 2019 02:01:26 -0800 Subject: [PATCH] documentation: support for scripting auth environment variables --- documentation/cn/api-scripting-support.md | 3 ++ documentation/cn/updating-lotus.md | 3 ++ documentation/en/api-scripting-support.md | 31 +++++++++++++++++++++ documentation/en/api.md | 34 +++++++++++------------ documentation/en/join-devnet.md | 2 +- documentation/en/mining.md | 4 ++- 6 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 documentation/cn/api-scripting-support.md create mode 100644 documentation/cn/updating-lotus.md create mode 100644 documentation/en/api-scripting-support.md diff --git a/documentation/cn/api-scripting-support.md b/documentation/cn/api-scripting-support.md new file mode 100644 index 000000000..4f16a070a --- /dev/null +++ b/documentation/cn/api-scripting-support.md @@ -0,0 +1,3 @@ +# API Scripting Support + +工作正在进行中 diff --git a/documentation/cn/updating-lotus.md b/documentation/cn/updating-lotus.md new file mode 100644 index 000000000..fcf1ec4f9 --- /dev/null +++ b/documentation/cn/updating-lotus.md @@ -0,0 +1,3 @@ +# Updating Lotus + +工作正在进行中 \ No newline at end of file diff --git a/documentation/en/api-scripting-support.md b/documentation/en/api-scripting-support.md new file mode 100644 index 000000000..27bc59aa5 --- /dev/null +++ b/documentation/en/api-scripting-support.md @@ -0,0 +1,31 @@ +# API Scripting Support + +You may want to delegate the work **Lotus Storage Miner** or **Lotus Node** perform to other machines. Here is how to setup the necessary authorization and environment variables. + +## Generate a JWT + +To generate a JWT for your environment variables, use this command: + +```sh +lotus auth create-token --perm admin +lotus-storage-miner auth create-token --perm admin +``` + +## Environment variables + +Environmental variables are variables that are defined for the current shell and are inherited by any child shells or processes. Environmental variables are used to pass information into processes that are spawned from the shell. + +Using the JWT you generated, you can assign it and the **multiaddr** to the appropriate environment variable. + +```sh +# Lotus Node +FULLNODE_API_INFO="JWT_TOKEN:/ip4/127.0.0.1/tcp/1234/http" + +# Lotus Storage Miner +STORAGE_API_INFO="JWT_TOKEN:/ip4/127.0.0.1/tcp/2345/http" +``` + +* The **Lotus Node**'s `mutliaddr` is in `~/.lotus/api`. +* The default token is in `~/.lotus/token`. +* The **Lotus Storage Miner**'s `multiaddr` is in `~/.lotusstorage/config`. +* The default token is in `~/.lotusstorage/token`. \ No newline at end of file diff --git a/documentation/en/api.md b/documentation/en/api.md index bb6791206..b32a38782 100644 --- a/documentation/en/api.md +++ b/documentation/en/api.md @@ -49,7 +49,7 @@ curl -X POST \ > In the future we will add a playground to make it easier to build and experiment with API requests. -## Authorization +## CURL authorization To authorize your request, you will need to include the **JWT** in a HTTP header, for example: @@ -59,23 +59,23 @@ To authorize your request, you will need to include the **JWT** in a HTTP header Admin token is stored in `~/.lotus/token` for the **Lotus Node** or `~/.lotusstorage/token` for the **Lotus Storage Miner**. -## Authorization types +## How do I generate a token? + +To generate a JWT with custom permissions, use this command: + +```sh +# Lotus Node +lotus auth create-token --perm admin + +# Lotus Storage Miner +lotus-storage-miner auth create-token --perm admin +``` + +## What authorization level should I use? When viewing [api/struct.go](https://github.com/filecoin-project/lotus/blob/master/api/struct.go), you will encounter these types: - `read` - Read node state, no private data. -- `write` - Write to local store / chain, read private data. -- `sign` - Use private keys stored in wallet for signing. -- `admin` - Manage permissions. - -Payload - -```json -{ - "Allow": [ - "read", - "write", - /* other options */ - ] -} -``` +- `write` - Write to local store / chain, and `read` permissions. +- `sign` - Use private keys stored in wallet for signing, `read` and `write` permissions. +- `admin` - Manage permissions, `read`, `write`, and `sign` permissions. diff --git a/documentation/en/join-devnet.md b/documentation/en/join-devnet.md index ac8c8dd1c..9a40ce107 100644 --- a/documentation/en/join-devnet.md +++ b/documentation/en/join-devnet.md @@ -49,7 +49,7 @@ Here is an example of the response t3vhfme4qfvegqaz7m7q6o6afjcs67n6kpzv7t2eozio4chwpafwa2y4l7zhwd5eom7jmihzdg4s52dpvnclza ``` -- Visit the [faucet](https://lotus-faucet.kittyhawk.wtf/funds.html) +- Visit the [faucet](https://lotus-faucet.kittyhawk.wtf/funds.html) to add funds. - Paste the address you created. - Press the send button. diff --git a/documentation/en/mining.md b/documentation/en/mining.md index e9b338c64..d0b0d1cf4 100644 --- a/documentation/en/mining.md +++ b/documentation/en/mining.md @@ -17,7 +17,7 @@ lotus wallet list With your wallet address: - Visit the [faucet](https://lotus-faucet.kittyhawk.wtf/miner.html) -- Click "Create Miner +- Click "Create Miner" - DO NOT REFRESH THE PAGE. THIS OPERATION CAN TAKE SOME TIME. The task will be complete when you see: @@ -50,6 +50,8 @@ To mine: lotus-storage-miner run ``` +If you are downloading **Filecoin Parameters**, the download can take some time. + Get information about your miner: ```sh