public void UserAuth() { logger.Info("Start Authentication " + "ws://" + pushServer); IRpcAuthentication auth = channel.GetRpcProxy <IRpcAuthentication>(); object obj = auth.Auth(signature, session.UserKey, session.UserKey); logger.Info("Successfully Authentication " + "ws://" + pushServer); }
public void long_key_tests(string token, bool expected) { ManualTimestamper manualTimestamper = new() { UtcNow = DateTimeOffset.FromUnixTimeSeconds(1644994971).UtcDateTime }; IRpcAuthentication authentication = MicrosoftJwtAuthentication.CreateFromHexSecret("5166546A576E5A7234753778214125442A472D4A614E645267556B5870327335", manualTimestamper, LimboTraceLogger.Instance); IRpcAuthentication authenticationWithPrefix = MicrosoftJwtAuthentication.CreateFromHexSecret("0x5166546A576E5A7234753778214125442A472D4A614E645267556B5870327335", manualTimestamper, LimboTraceLogger.Instance); bool actual = authentication.Authenticate(token); Assert.AreEqual(expected, actual); actual = authenticationWithPrefix.Authenticate(token); Assert.AreEqual(actual, expected); } }
public JsonRpcRunner( IJsonRpcProcessor jsonRpcProcessor, IJsonRpcUrlCollection jsonRpcUrlCollection, IWebSocketsManager webSocketsManager, IConfigProvider configurationProvider, IRpcAuthentication rpcAuthentication, ILogManager logManager, INethermindApi api) { _jsonRpcConfig = configurationProvider.GetConfig <IJsonRpcConfig>(); _initConfig = configurationProvider.GetConfig <IInitConfig>(); _configurationProvider = configurationProvider; _rpcAuthentication = rpcAuthentication; _jsonRpcUrlCollection = jsonRpcUrlCollection; _logManager = logManager; _jsonRpcProcessor = jsonRpcProcessor; _webSocketsManager = webSocketsManager; _logger = logManager.GetClassLogger(); _api = api; }
public async Task Execute(CancellationToken cancellationToken) { IJsonRpcConfig jsonRpcConfig = _api.Config <IJsonRpcConfig>(); ILogger logger = _api.LogManager.GetClassLogger(); if (jsonRpcConfig.Enabled) { IInitConfig initConfig = _api.Config <IInitConfig>(); IJsonRpcUrlCollection jsonRpcUrlCollection = new JsonRpcUrlCollection(_api.LogManager, jsonRpcConfig, initConfig.WebSocketsEnabled); JsonRpcLocalStats jsonRpcLocalStats = new( _api.Timestamper, jsonRpcConfig, _api.LogManager); IRpcModuleProvider rpcModuleProvider = _api.RpcModuleProvider !; JsonRpcService jsonRpcService = new(rpcModuleProvider, _api.LogManager, jsonRpcConfig); IJsonSerializer jsonSerializer = CreateJsonSerializer(jsonRpcService); IRpcAuthentication auth = jsonRpcConfig.UnsecureDevNoRpcAuthentication || !jsonRpcUrlCollection.Values.Any(u => u.IsAuthenticated) ? NoAuthentication.Instance : MicrosoftJwtAuthentication.CreateFromFileOrGenerate(jsonRpcConfig.JwtSecretFile, _api.Timestamper, logger); JsonRpcProcessor jsonRpcProcessor = new( jsonRpcService, jsonSerializer, jsonRpcConfig, _api.FileSystem, _api.LogManager); if (initConfig.WebSocketsEnabled) { JsonRpcWebSocketsModule webSocketsModule = new( jsonRpcProcessor, jsonRpcService, jsonRpcLocalStats, _api.LogManager, jsonSerializer, jsonRpcUrlCollection, auth); _api.WebSocketsManager !.AddModule(webSocketsModule, true); } Bootstrap.Instance.JsonRpcService = jsonRpcService; Bootstrap.Instance.LogManager = _api.LogManager; Bootstrap.Instance.JsonSerializer = jsonSerializer; Bootstrap.Instance.JsonRpcLocalStats = jsonRpcLocalStats; Bootstrap.Instance.JsonRpcAuthentication = auth; JsonRpcRunner?jsonRpcRunner = new( jsonRpcProcessor, jsonRpcUrlCollection, _api.WebSocketsManager !, _api.ConfigProvider, auth, _api.LogManager, _api); await jsonRpcRunner.Start(cancellationToken).ContinueWith(x => { if (x.IsFaulted && logger.IsError) { logger.Error("Error during jsonRpc runner start", x.Exception); } }, cancellationToken); JsonRpcIpcRunner jsonIpcRunner = new(jsonRpcProcessor, jsonRpcService, _api.ConfigProvider, _api.LogManager, jsonRpcLocalStats, jsonSerializer, _api.FileSystem); jsonIpcRunner.Start(cancellationToken); #pragma warning disable 4014 _api.DisposeStack.Push( new Reactive.AnonymousDisposable(() => jsonRpcRunner.StopAsync())); // do not await _api.DisposeStack.Push(jsonIpcRunner); // do not await #pragma warning restore 4014 } else { if (logger.IsInfo) { logger.Info("Json RPC is disabled"); } } }