1bf713cb0a
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
44 lines
760 B
Go
44 lines
760 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gopkg.in/urfave/cli.v2"
|
|
|
|
"github.com/filecoin-project/lotus/api"
|
|
)
|
|
|
|
var authCmd = &cli.Command{
|
|
Name: "auth",
|
|
Usage: "Manage RPC permissions",
|
|
Subcommands: []*cli.Command{
|
|
authCreateAdminToken,
|
|
},
|
|
}
|
|
|
|
var authCreateAdminToken = &cli.Command{
|
|
Name: "create-admin-token",
|
|
Usage: "Create admin token",
|
|
Action: func(cctx *cli.Context) error {
|
|
napi, closer, err := GetFullNodeAPI(cctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer closer()
|
|
|
|
ctx := ReqContext(cctx)
|
|
|
|
// TODO: Probably tell the user how powerful this token is
|
|
|
|
token, err := napi.AuthNew(ctx, api.AllPermissions)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// TODO: Log in audit log when it is implemented
|
|
|
|
fmt.Println(string(token))
|
|
return nil
|
|
},
|
|
}
|