public async Task <IdentityResult> LoginAsync(HttpContext httpContext, NexusNodeEndpoint nodeEndpoint, bool isPersistent = false, CancellationToken token = default) { if (httpContext.User.Identity.IsAuthenticated) { return(IdentityResult.Failed(new IdentityError { Description = "Already signed in" })); } var nexusNode = new NexusNode((INexusClient)httpContext.RequestServices.GetService(typeof(INexusClient)), nodeEndpoint); var response = await nexusNode.Client.GetAsync("ledger/mininginfo", "Connection attempt", null, token, true); if (!response.IsSuccessStatusCode) { return(IdentityResult.Failed(new IdentityError { Description = "Unable to connect to node endpoint" })); } var claims = new List <Claim> { new Claim(_cookeConstants.NodeIdClaimType, nodeEndpoint.Name) }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var principal = new ClaimsPrincipal(identity); await httpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal); return(IdentityResult.Success); }
public T Get <T>(NexusNodeEndpoint nodeEndpoint) where T : NexusService { var nexusNode = new NexusNode(_serviceProvider.GetService <INexusClient>(), nodeEndpoint); var service = Activator.CreateInstance(typeof(T), nexusNode, _serviceProvider.GetService <ILogger <NexusService> >()); return((T)service); }
public async Task <T> GetAsync <T>(HttpContext context) where T : NexusService { var nexusNode = new NexusNode(_serviceProvider.GetService <INexusClient>(), await _nodeManager.GetCurrentEndpointAsync(context)); var service = Activator.CreateInstance(typeof(T), nexusNode, _serviceProvider.GetService <ILogger <NexusService> >()); return((T)service); }
public AccountService(NexusNode node, ILogger <NexusService> log) : base(node, log) { }
public TokenService(NexusNode node, ILogger <NexusService> log) : base(node, log) { }
public LedgerService(NexusNode node, ILogger <NexusService> log) : base(node, log) { }