mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #927 from wabbajack-tools/version-2.0.9.4
Version 2.0.9.4
This commit is contained in:
commit
91cf230641
@ -1,9 +1,12 @@
|
||||
### Changelog
|
||||
|
||||
#### Version - 2.0.9.3 - 6/8/2020
|
||||
#### Version - 2.0.9.4 - 6/16/2020
|
||||
* Improve interactions between server and client code
|
||||
|
||||
#### Version - 2.0.9.3 - 6/14/2020
|
||||
* Retry 503s not all 500s
|
||||
|
||||
#### Version - 2.0.9.2 - 6/8/2020
|
||||
#### Version - 2.0.9.2 - 6/13/2020
|
||||
* Several bug fixes
|
||||
* Added Darkest Dungeon as a game to alpha test non Bethesda MO2 game integration
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<AssemblyName>wabbajack-cli</AssemblyName>
|
||||
<Company>Wabbajack</Company>
|
||||
<Platforms>x64</Platforms>
|
||||
<AssemblyVersion>2.0.9.3</AssemblyVersion>
|
||||
<FileVersion>2.0.9.3</FileVersion>
|
||||
<AssemblyVersion>2.0.9.4</AssemblyVersion>
|
||||
<FileVersion>2.0.9.4</FileVersion>
|
||||
<Copyright>Copyright © 2019-2020</Copyright>
|
||||
<Description>An automated ModList installer</Description>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
|
@ -141,5 +141,12 @@ namespace Wabbajack.Common.Http
|
||||
doc.LoadHtml(body);
|
||||
return doc;
|
||||
}
|
||||
|
||||
public Client WithHeader((string MetricsKeyHeader, string) header)
|
||||
{
|
||||
var newHeaders = Headers.Cons(header).ToList();
|
||||
var client = new Client {Headers = newHeaders, Cookies = Cookies,};
|
||||
return client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
<AssemblyVersion>2.0.9.3</AssemblyVersion>
|
||||
<FileVersion>2.0.9.3</FileVersion>
|
||||
<AssemblyVersion>2.0.9.4</AssemblyVersion>
|
||||
<FileVersion>2.0.9.4</FileVersion>
|
||||
<Copyright>Copyright © 2019-2020</Copyright>
|
||||
<Description>Wabbajack Application Launcher</Description>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
|
@ -125,7 +125,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
var tempFile = new TempFile();
|
||||
|
||||
using var response = await (new Common.Http.Client()).GetAsync(patchResult);
|
||||
using var response = await (await ClientAPI.GetClient()).GetAsync(patchResult);
|
||||
await tempFile.Path.WriteAllAsync(await response.Content.ReadAsStreamAsync());
|
||||
response.Dispose();
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
using (var fs = download ? await destination.Create() : null)
|
||||
{
|
||||
var client = Client ?? new Common.Http.Client();
|
||||
var client = Client ?? await ClientAPI.GetClient();
|
||||
client.Headers.Add(("User-Agent", Consts.UserAgent));
|
||||
|
||||
foreach (var header in Headers)
|
||||
|
@ -11,6 +11,7 @@ using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using System.Threading;
|
||||
using Wabbajack.Common.Exceptions;
|
||||
using Wabbajack.Common.Http;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
|
||||
namespace Wabbajack.Lib.NexusApi
|
||||
@ -254,13 +255,14 @@ namespace Wabbajack.Lib.NexusApi
|
||||
return new NexusApiClient(apiKey);
|
||||
}
|
||||
|
||||
public async Task<T> Get<T>(string url)
|
||||
public async Task<T> Get<T>(string url, Client? client = null)
|
||||
{
|
||||
client ??= HttpClient;
|
||||
int retries = 0;
|
||||
TOP:
|
||||
try
|
||||
{
|
||||
using var response = await HttpClient.GetAsync(url);
|
||||
using var response = await client.GetAsync(url);
|
||||
await UpdateRemaining(response);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
@ -297,7 +299,7 @@ namespace Wabbajack.Lib.NexusApi
|
||||
Scheme = Consts.WabbajackBuildServerUri.Scheme,
|
||||
Port = Consts.WabbajackBuildServerUri.Port
|
||||
};
|
||||
return await Get<T>(builder.ToString());
|
||||
return await Get<T>(builder.ToString(), HttpClient.WithHeader((Consts.MetricsKeyHeader, await Metrics.GetMetricsKey())));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ using Wabbajack.Lib.FileUploader;
|
||||
using Wabbajack.Lib.ModListRegistry;
|
||||
using Wabbajack.Server;
|
||||
using Wabbajack.Server.DataLayer;
|
||||
using Wabbajack.Server.DTOs;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
@ -41,7 +42,7 @@ namespace Wabbajack.BuildServer.Test
|
||||
await base.InitializeAsync();
|
||||
ServerArchivesFolder.DeleteDirectory().Wait();
|
||||
ServerArchivesFolder.CreateDirectory();
|
||||
|
||||
|
||||
var builder = Program.CreateHostBuilder(
|
||||
new[]
|
||||
{
|
||||
@ -65,6 +66,15 @@ namespace Wabbajack.BuildServer.Test
|
||||
await "ServerWhitelist.yaml".RelativeTo(ServerPublicFolder).WriteAllTextAsync(
|
||||
"GoogleIDs:\nAllowedPrefixes:\n - http://localhost");
|
||||
|
||||
var sql = GetService<SqlService>();
|
||||
await sql.IngestMetric(new Metric
|
||||
{
|
||||
Action = "start",
|
||||
Subject = "tests",
|
||||
Timestamp = DateTime.UtcNow,
|
||||
MetricsKey = await Metrics.GetMetricsKey()
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
~BuildServerFixture()
|
||||
|
@ -55,27 +55,42 @@ namespace Wabbajack.BuildServer
|
||||
}
|
||||
}
|
||||
|
||||
if (!Request.Headers.TryGetValue(ApiKeyHeaderName, out var apiKeyHeaderValues))
|
||||
var authorKey = Request.Headers[ApiKeyHeaderName].FirstOrDefault();
|
||||
|
||||
if (authorKey == null && metricsKey == null)
|
||||
{
|
||||
return AuthenticateResult.NoResult();
|
||||
}
|
||||
|
||||
|
||||
var providedApiKey = apiKeyHeaderValues.FirstOrDefault();
|
||||
|
||||
if (apiKeyHeaderValues.Count == 0 || string.IsNullOrWhiteSpace(providedApiKey))
|
||||
if (authorKey != null)
|
||||
{
|
||||
return AuthenticateResult.NoResult();
|
||||
}
|
||||
var owner = await _sql.LoginByApiKey(authorKey);
|
||||
if (owner == null)
|
||||
return AuthenticateResult.Fail("Invalid author key");
|
||||
|
||||
var owner = await _sql.LoginByApiKey(providedApiKey);
|
||||
|
||||
if (owner != null)
|
||||
{
|
||||
var claims = new List<Claim> {new Claim(ClaimTypes.Name, owner)};
|
||||
|
||||
/*
|
||||
claims.AddRange(existingApiKey.Roles.Select(role => new Claim(ClaimTypes.Role, role)));
|
||||
*/
|
||||
claims.Add(new Claim(ClaimTypes.Role, "Author"));
|
||||
claims.Add(new Claim(ClaimTypes.Role, "User"));
|
||||
|
||||
var identity = new ClaimsIdentity(claims, Options.AuthenticationType);
|
||||
var identities = new List<ClaimsIdentity> {identity};
|
||||
var principal = new ClaimsPrincipal(identities);
|
||||
var ticket = new AuthenticationTicket(principal, Options.Scheme);
|
||||
|
||||
return AuthenticateResult.Success(ticket);
|
||||
}
|
||||
|
||||
if (!await _sql.ValidMetricsKey(metricsKey))
|
||||
{
|
||||
return AuthenticateResult.Fail("Invalid Metrics Key");
|
||||
}
|
||||
else
|
||||
{
|
||||
var claims = new List<Claim>();
|
||||
|
||||
claims.Add(new Claim(ClaimTypes.Role, "User"));
|
||||
|
||||
var identity = new ClaimsIdentity(claims, Options.AuthenticationType);
|
||||
var identities = new List<ClaimsIdentity> {identity};
|
||||
@ -85,7 +100,6 @@ namespace Wabbajack.BuildServer
|
||||
return AuthenticateResult.Success(ticket);
|
||||
}
|
||||
|
||||
return AuthenticateResult.Fail("Invalid API Key provided.");
|
||||
}
|
||||
|
||||
[JsonName("RequestLog")]
|
||||
@ -103,7 +117,10 @@ namespace Wabbajack.BuildServer
|
||||
Headers = Request.Headers.GroupBy(s => s.Key)
|
||||
.ToDictionary(s => s.Key, s => s.SelectMany(v => v.Value).ToArray())
|
||||
};
|
||||
await _sql.IngestAccess(Request.HttpContext.Connection.RemoteIpAddress.ToString(), action.ToJson());
|
||||
var ip = Request.Headers["CF-Connecting-IP"].FirstOrDefault() ??
|
||||
Request.Headers["X-Forwarded-For"].FirstOrDefault() ??
|
||||
Request.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
await _sql.IngestAccess(ip, action.ToJson());
|
||||
}
|
||||
|
||||
protected override async Task HandleChallengeAsync(AuthenticationProperties properties)
|
||||
|
@ -17,7 +17,7 @@ using Wabbajack.Server.DTOs;
|
||||
|
||||
namespace Wabbajack.BuildServer.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[Authorize(Roles = "Author")]
|
||||
[Route("/authored_files")]
|
||||
public class AuthoredFiles : ControllerBase
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Wabbajack.Common;
|
||||
@ -29,6 +30,7 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
|
||||
|
||||
[Route("ingest")]
|
||||
[Authorize(Roles = "User")]
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostIngest()
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Wabbajack.Common;
|
||||
@ -27,6 +28,7 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize(Roles = "User")]
|
||||
[Route("/mod_upgrade")]
|
||||
public async Task<IActionResult> PostModUpgrade()
|
||||
{
|
||||
|
@ -18,6 +18,7 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
{
|
||||
//[Authorize]
|
||||
[ApiController]
|
||||
[Authorize(Roles = "User")]
|
||||
[Route("/v1/games/")]
|
||||
public class NexusCache : ControllerBase
|
||||
{
|
||||
|
@ -1,11 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Wabbajack.BuildServer.Controllers
|
||||
{
|
||||
|
||||
[ApiController]
|
||||
public class UploadedFiles
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -56,14 +56,21 @@ namespace Wabbajack.Server.DataLayer
|
||||
return (await conn.QueryAsync<(DateTime, string, string)>(@"
|
||||
SELECT u.Timestamp, u.Path, u.MetricsKey FROM
|
||||
(SELECT al.Timestamp, JSON_VALUE(al.Action, '$.Path') as Path, al.MetricsKey FROM dbo.AccessLog al
|
||||
WHERE al.MetricsKey in (SELECT DISTINCT MetricsKey from AccessLog al WHERE al.Ip in (SELECT DISTINCT Ip from AccessLog where MetricsKey = @MetricsKey))
|
||||
WHERE al.MetricsKey = @MetricsKey
|
||||
UNION ALL
|
||||
SELECT m.Timestamp, m.Action + ' ' + m.Subject as Path, m.MetricsKey FROM dbo.Metrics m
|
||||
WHERE m.MetricsKey in (SELECT DISTINCT MetricsKey from AccessLog al WHERE al.Ip in (SELECT DISTINCT Ip from AccessLog where MetricsKey = @MetricsKey)
|
||||
AND m.Action != 'TarKey')) u
|
||||
WHERE m.MetricsKey = @MetricsKey
|
||||
AND m.Action != 'TarKey') u
|
||||
ORDER BY u.Timestamp Desc",
|
||||
new {MetricsKey = key})).ToList();
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> ValidMetricsKey(string metricsKey)
|
||||
{
|
||||
await using var conn = await Open();
|
||||
return (await conn.QueryAsync<string>("SELECT TOP(1) MetricsKey from Metrics Where MetricsKey = @MetricsKey",
|
||||
new {MetricsKey = metricsKey})).FirstOrDefault() != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AssemblyVersion>2.0.9.3</AssemblyVersion>
|
||||
<FileVersion>2.0.9.3</FileVersion>
|
||||
<AssemblyVersion>2.0.9.4</AssemblyVersion>
|
||||
<FileVersion>2.0.9.4</FileVersion>
|
||||
<Copyright>Copyright © 2019-2020</Copyright>
|
||||
<Description>Wabbajack Server</Description>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
@ -47,5 +47,9 @@
|
||||
<EmbeddedResource Include="sheo_quotes.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Controllers\UploadedFiles.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
@ -6,8 +6,8 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
<Platforms>x64</Platforms>
|
||||
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
|
||||
<AssemblyVersion>2.0.9.3</AssemblyVersion>
|
||||
<FileVersion>2.0.9.3</FileVersion>
|
||||
<AssemblyVersion>2.0.9.4</AssemblyVersion>
|
||||
<FileVersion>2.0.9.4</FileVersion>
|
||||
<Copyright>Copyright © 2019-2020</Copyright>
|
||||
<Description>An automated ModList installer</Description>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
|
Loading…
Reference in New Issue
Block a user