Ejemplo n.º 1
0
 public static Task <ClientAuthenticationResponse> Authenticate(ClientAuthenticationDto dto, IRestClient client)
 {
     return(CreateRequest(HttpVerb.Post, "login", new JsonContent(dto, settings =>
     {
         settings.Converters.Add(new NuGetFrameworkConverter());
         settings.Converters.Add(new NuGetVersionConverter());
     })).Execute(client).Wrap <ClientAuthenticationResponse>().ConfigureJsonSettings(settings =>
     {
         settings.Converters.Add(new PackageIdentityConverter());
     }).ToResult());
 }
Ejemplo n.º 2
0
        public ClientAuthenticationDto GetAuthenticationDto()
        {
            var result = new ClientAuthenticationDto
            {
                ClientVersion   = _applicationInfo.Version,
                Framework       = _applicationInfo.Framework,
                Username        = Environment.UserName,
                OperatingSystem = Environment.OSVersion.ToString(),
                SystemLanguage  = CultureInfo.CurrentUICulture.ToString(),
                IsAdministrator = false,
                ClientPath      = Application.StartupPath,
                HardwareId      = "FF",
                MacAddress      = new byte[] { 1, 1, 1, 1, 1, 1 }
            };

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Login([FromBody] ClientAuthenticationDto authenticationDto,
                                                [FromServices] IAuthenticateClientAction authenticateClientAction,
                                                [FromServices] ITokenProvider tokenProvider,
                                                [FromServices] IModulePackageManager modulePackageManager)
        {
            var client = await authenticateClientAction.ToRunner(_context).ExecuteAsync(new ClientAuthenticationContext
            {
                Dto       = authenticationDto,
                IpAddress = HttpContext.Connection.RemoteIpAddress
            });

            return(await BizActionStatus(authenticateClientAction, async() =>
            {
                var token = tokenProvider.GetClientToken(client);
                return Ok(new ClientAuthenticationResponse
                {
                    Jwt = tokenProvider.TokenToString(token),
                    Modules = await modulePackageManager.GetPackagesLock(authenticationDto.Framework)
                });
            }));
        }