documentation: support for scripting auth environment variables

This commit is contained in:
wwwjim 2019-12-10 02:01:26 -08:00
parent 8c685730d2
commit 168661133c
6 changed files with 58 additions and 19 deletions

View File

@ -0,0 +1,3 @@
# API Scripting Support
工作正在进行中

View File

@ -0,0 +1,3 @@
# Updating Lotus
工作正在进行中

View File

@ -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`.

View File

@ -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.

View File

@ -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.

View File

@ -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