node: allow JWT pass by file only (#24579)

pull/24583/head
Marius van der Wijden 3 years ago committed by GitHub
parent 535f25d65f
commit a8040bc2c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cmd/utils/flags.go
  2. 13
      node/node.go

@ -548,7 +548,7 @@ var (
} }
JWTSecretFlag = cli.StringFlag{ JWTSecretFlag = cli.StringFlag{
Name: "authrpc.jwtsecret", Name: "authrpc.jwtsecret",
Usage: "JWT secret (or path to a jwt secret) to use for authenticated RPC endpoints", Usage: "Path to a JWT secret to use for authenticated RPC endpoints",
} }
// Logging and debug settings // Logging and debug settings
EthStatsURLFlag = cli.StringFlag{ EthStatsURLFlag = cli.StringFlag{

@ -346,17 +346,8 @@ func (n *Node) closeDataDir() {
// or from the default location. If neither of those are present, it generates // or from the default location. If neither of those are present, it generates
// a new secret and stores to the default location. // a new secret and stores to the default location.
func (n *Node) obtainJWTSecret(cliParam string) ([]byte, error) { func (n *Node) obtainJWTSecret(cliParam string) ([]byte, error) {
var fileName string fileName := cliParam
if len(cliParam) > 0 { if len(fileName) == 0 {
// If a plaintext secret was provided via cli flags, use that
jwtSecret := common.FromHex(cliParam)
if len(jwtSecret) == 32 && strings.HasPrefix(cliParam, "0x") {
log.Warn("Plaintext JWT secret provided, please consider passing via file")
return jwtSecret, nil
}
// path provided
fileName = cliParam
} else {
// no path provided, use default // no path provided, use default
fileName = n.ResolvePath(datadirJWTKey) fileName = n.ResolvePath(datadirJWTKey)
} }

Loading…
Cancel
Save