cmd/geth, node, rpc: implement jwt tokens (#24364)
* rpc, node: refactor request validation and add jwt validation * node, rpc: fix error message, ignore engine api in RegisterAPIs * node: make authenticated port configurable * eth/catalyst: enable unauthenticated version of engine api * node: rework obtainjwtsecret (backport later) * cmd/geth: added auth port flag * node: happy lint, happy life * node: refactor authenticated api Modifies the authentication mechanism to use default values * node: trim spaces and newline away from secret Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
This commit is contained in:
committed by
GitHub
parent
37f9d25ba0
commit
4860e50e05
@ -518,6 +518,16 @@ var (
|
||||
Usage: "Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)",
|
||||
Value: ethconfig.Defaults.RPCTxFeeCap,
|
||||
}
|
||||
// Authenticated port settings
|
||||
AuthPortFlag = cli.IntFlag{
|
||||
Name: "authrpc.port",
|
||||
Usage: "Listening port for authenticated APIs",
|
||||
Value: node.DefaultAuthPort,
|
||||
}
|
||||
JWTSecretFlag = cli.StringFlag{
|
||||
Name: "authrpc.jwtsecret",
|
||||
Usage: "JWT secret (or path to a jwt secret) to use for authenticated RPC endpoints",
|
||||
}
|
||||
// Logging and debug settings
|
||||
EthStatsURLFlag = cli.StringFlag{
|
||||
Name: "ethstats",
|
||||
@ -951,6 +961,10 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) {
|
||||
cfg.HTTPPort = ctx.GlobalInt(HTTPPortFlag.Name)
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(AuthPortFlag.Name) {
|
||||
cfg.AuthPort = ctx.GlobalInt(AuthPortFlag.Name)
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(HTTPCORSDomainFlag.Name) {
|
||||
cfg.HTTPCors = SplitAndTrim(ctx.GlobalString(HTTPCORSDomainFlag.Name))
|
||||
}
|
||||
@ -1218,6 +1232,10 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
|
||||
setDataDir(ctx, cfg)
|
||||
setSmartCard(ctx, cfg)
|
||||
|
||||
if ctx.GlobalIsSet(JWTSecretFlag.Name) {
|
||||
cfg.JWTSecret = ctx.GlobalString(JWTSecretFlag.Name)
|
||||
}
|
||||
|
||||
if ctx.GlobalIsSet(ExternalSignerFlag.Name) {
|
||||
cfg.ExternalSigner = ctx.GlobalString(ExternalSignerFlag.Name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user