lotus/cli/auth.go

44 lines
763 B
Go
Raw Normal View History

2019-09-18 17:53:48 +00:00
package cli
import (
"fmt"
"gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/go-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 {
2019-10-03 18:12:30 +00:00
napi, closer, err := GetFullNodeAPI(cctx)
2019-09-18 17:53:48 +00:00
if err != nil {
return err
}
2019-10-03 18:12:30 +00:00
defer closer()
2019-09-18 17:53:48 +00:00
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
},
}