mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
a797a7aaac
* builds * initialize auth token from scratch * change auth * add improvements * moar auth fixes * web auth changes running * url encode * tests * gaz * navigate auth * separate line * auth token * 304 * persistent auth tokens and jwts * fixed up test * auth token path test and integration test * auth token test * auth token command * gaz * gaz * Radek feedback * fix up * test * Update validator/rpc/auth_token.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/prysmaticlabs/prysm/cmd"
|
|
"github.com/prysmaticlabs/prysm/cmd/validator/flags"
|
|
"github.com/prysmaticlabs/prysm/config/features"
|
|
"github.com/prysmaticlabs/prysm/runtime/tos"
|
|
"github.com/prysmaticlabs/prysm/validator/rpc"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// Commands for managing Prysm validator accounts.
|
|
var Commands = &cli.Command{
|
|
Name: "web",
|
|
Category: "web",
|
|
Usage: "defines commands for interacting with the Prysm web interface",
|
|
Subcommands: []*cli.Command{
|
|
{
|
|
Name: "generate-auth-token",
|
|
Description: `Generate an authentication token for the Prysm web interface`,
|
|
Flags: cmd.WrapFlags([]cli.Flag{
|
|
flags.WalletDirFlag,
|
|
flags.GRPCGatewayHost,
|
|
flags.GRPCGatewayPort,
|
|
cmd.AcceptTosFlag,
|
|
}),
|
|
Before: func(cliCtx *cli.Context) error {
|
|
if err := cmd.LoadFlagsFromConfig(cliCtx, cliCtx.Command.Flags); err != nil {
|
|
return err
|
|
}
|
|
return tos.VerifyTosAcceptedOrPrompt(cliCtx)
|
|
},
|
|
Action: func(cliCtx *cli.Context) error {
|
|
features.ConfigureValidator(cliCtx)
|
|
walletDirPath := cliCtx.String(flags.WalletDirFlag.Name)
|
|
if walletDirPath == "" {
|
|
log.Fatal("--wallet-dir not specified")
|
|
}
|
|
gatewayHost := cliCtx.String(flags.GRPCGatewayHost.Name)
|
|
gatewayPort := cliCtx.Int(flags.GRPCGatewayPort.Name)
|
|
validatorWebAddr := fmt.Sprintf("%s:%d", gatewayHost, gatewayPort)
|
|
if err := rpc.CreateAuthToken(walletDirPath, validatorWebAddr); err != nil {
|
|
log.Fatalf("Could not create web auth token: %v", err)
|
|
}
|
|
return nil
|
|
},
|
|
},
|
|
},
|
|
}
|