Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7746 jwtfile path correction #7765

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f11fcfa
jwtfile path correction
ssonthal Nov 18, 2024
f4fd623
Some fixes
ssonthal Nov 18, 2024
a104cf8
default as null explicitly
ssonthal Nov 18, 2024
64ef390
suggested changes
ssonthal Nov 19, 2024
731588e
suggested changes
ssonthal Nov 19, 2024
a9708a8
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 19, 2024
1d32886
Update JsonRpcConfig.cs
ssonthal Nov 19, 2024
c200cfd
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 20, 2024
b357386
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 21, 2024
50612b7
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 21, 2024
3d507d1
suggested changes
ssonthal Nov 21, 2024
2e9d08a
adding warning messages
ssonthal Nov 21, 2024
3d58984
typo fix
ssonthal Nov 21, 2024
493ea51
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 21, 2024
cb8d026
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 22, 2024
50575b1
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
91cd1d9
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
b2d2478
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
f209b7e
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
7b9c341
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
b93a9b7
suggested changes
ssonthal Nov 27, 2024
516f362
DefaultValue = null
ssonthal Nov 27, 2024
6f2a12c
oldPath
ssonthal Nov 27, 2024
274bd79
removing extra line
ssonthal Nov 27, 2024
7eb7591
Update: Log expanded path of jwt-secret files instead of relative paths
obasekiosa Nov 27, 2024
5fb5931
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 27, 2024
102b1bf
jwtfile path correction
ssonthal Nov 18, 2024
2a2b6e4
Some fixes
ssonthal Nov 18, 2024
594631d
suggested changes
ssonthal Nov 19, 2024
326fb39
suggested changes
ssonthal Nov 19, 2024
1f4d596
Update JsonRpcConfig.cs
ssonthal Nov 19, 2024
a6ad9df
suggested changes
ssonthal Nov 21, 2024
07d3943
adding warning messages
ssonthal Nov 21, 2024
bb4b54e
typo fix
ssonthal Nov 21, 2024
d069c82
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
1b84964
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
807eba9
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
9adadc1
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
e418cf5
Update src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
ssonthal Nov 27, 2024
fb18100
suggested changes
ssonthal Nov 27, 2024
5d6e176
DefaultValue = null
ssonthal Nov 27, 2024
7fa3bc1
oldPath
ssonthal Nov 27, 2024
d5446ca
removing extra line
ssonthal Nov 27, 2024
9734684
Update: Log expanded path of jwt-secret files instead of relative paths
obasekiosa Nov 27, 2024
3813526
Merge branch '7746_update_jwt_path' of https://github.com/ssonthal/ne…
ssonthal Nov 27, 2024
50b4402
dotnet format
ssonthal Nov 27, 2024
d01639f
dotnet format
ssonthal Nov 27, 2024
73759eb
dotnet format
ssonthal Nov 27, 2024
5c89770
dotnet format
ssonthal Nov 27, 2024
3305bdc
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 28, 2024
26f7d29
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 28, 2024
ff42cd3
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 29, 2024
4d1386e
isWarn and oldPath on fail
ssonthal Nov 29, 2024
6148924
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 29, 2024
165b778
separate method
ssonthal Nov 29, 2024
3265475
dotnet format
ssonthal Nov 29, 2024
f9965f6
simplifying and dotnet format
ssonthal Nov 29, 2024
d9195e4
dotnet format
ssonthal Nov 29, 2024
cce722f
Merge branch 'master' into 7746_update_jwt_path
ssonthal Nov 29, 2024
29d40fc
Merge branch 'master' into 7746_update_jwt_path
ssonthal Dec 2, 2024
0cf237c
Merge branch 'master' into 7746_update_jwt_path
ssonthal Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.JsonRpc/IJsonRpcConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public interface IJsonRpcConfig : IConfig
""")]
int? EthModuleConcurrentInstances { get; set; }

[ConfigItem(Description = "The path to the JWT secret file required for the Engine API authentication.", DefaultValue = "keystore/jwt-secret")]
[ConfigItem(Description = "The path to the JWT secret file required for the Engine API authentication.", DefaultValue = "null")]
public string JwtSecretFile { get; set; }

[ConfigItem(Description = "Whether to disable authentication of the Engine API. Should not be used in production environments.", DefaultValue = "false", HiddenFromDocs = true)]
Expand Down
3 changes: 1 addition & 2 deletions src/Nethermind/Nethermind.JsonRpc/JsonRpcConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public int WebSocketsPort
public long? MaxRequestBodySize { get; set; } = 30000000;
public int MaxLogsPerResponse { get; set; } = 20_000;
public int? EthModuleConcurrentInstances { get; set; } = null;
public string JwtSecretFile { get; set; } = "keystore/jwt-secret";
public string JwtSecretFile { get; set; } = null;
public bool UnsecureDevNoRpcAuthentication { get; set; }
public int? MaxLoggedRequestParametersCharacters { get; set; } = null;
public string[]? MethodsLoggingFiltering { get; set; } =
Expand All @@ -58,4 +58,3 @@ public int WebSocketsPort
public int EstimateErrorMargin { get; set; } = 150;
public string[] CorsOrigins { get; set; } = ["*"];
};

32 changes: 32 additions & 0 deletions src/Nethermind/Nethermind.Runner/Ethereum/Steps/StartRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System.Linq;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Nethermind.Api;
Expand All @@ -14,6 +16,7 @@
using Nethermind.Logging;
using Nethermind.Runner.JsonRpc;
using Nethermind.Serialization.Json;
using Nethermind.KeyStore.Config;

namespace Nethermind.Runner.Ethereum.Steps
{
Expand All @@ -30,8 +33,37 @@ public StartRpc(INethermindApi api)
public async Task Execute(CancellationToken cancellationToken)
{
IJsonRpcConfig jsonRpcConfig = _api.Config<IJsonRpcConfig>();
IKeyStoreConfig keyStoreConfig = _api.Config<IKeyStoreConfig>();
ILogger logger = _api.LogManager.GetClassLogger();

if (string.IsNullOrEmpty(jsonRpcConfig.JwtSecretFile))
ssonthal marked this conversation as resolved.
Show resolved Hide resolved
{
string oldPath = "keystore/jwt-secret";
string newPath = Path.Join(keyStoreConfig.KeyStoreDirectory, "jwt-secret");
// check if jwt-secret file already exists in previous default directory
ssonthal marked this conversation as resolved.
Show resolved Hide resolved
if (!File.Exists(newPath) && File.Exists(oldPath))
{
obasekiosa marked this conversation as resolved.
Show resolved Hide resolved
oldPath = Path.GetFullPath(oldPath);
newPath = Path.GetFullPath(newPath);
try
{
File.Move(oldPath, newPath);
if (logger.IsWarn) {
logger.Warn($"Moved JWT secret from {oldPath} to {newPath}");
}
jsonRpcConfig.JwtSecretFile = newPath;
}
catch (Exception ex)
{
if (logger.IsError) logger.Error($"Failed moving JWT secret to {newPath}.", ex);
ssonthal marked this conversation as resolved.
Show resolved Hide resolved
jsonRpcConfig.JwtSecretFile = oldPath;
}
}
else {
jsonRpcConfig.JwtSecretFile = newPath;
}
}

if (jsonRpcConfig.Enabled)
{
IInitConfig initConfig = _api.Config<IInitConfig>();
Expand Down