Skip to content

Commit

Permalink
node: allow JWT pass by file only (ethereum#24579)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVanDerWijden authored and cp-wjhan committed Nov 16, 2022
1 parent 7eebcf5 commit 246da28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Expand Up @@ -552,7 +552,7 @@ var (
}
JWTSecretFlag = cli.StringFlag{
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
EthStatsURLFlag = cli.StringFlag{
Expand Down
13 changes: 2 additions & 11 deletions node/node.go
Expand Up @@ -346,17 +346,8 @@ func (n *Node) closeDataDir() {
// or from the default location. If neither of those are present, it generates
// a new secret and stores to the default location.
func (n *Node) obtainJWTSecret(cliParam string) ([]byte, error) {
var fileName string
if len(cliParam) > 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 {
fileName := cliParam
if len(fileName) == 0 {
// no path provided, use default
fileName = n.ResolvePath(datadirJWTKey)
}
Expand Down

0 comments on commit 246da28

Please sign in to comment.