Move projects to src; add Neutrino secret

This commit is contained in:
Holden
2026-06-19 22:52:38 -05:00
parent 2cfc5e7369
commit 95751904fa
90 changed files with 32 additions and 10 deletions

View File

@@ -1,18 +1,18 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.ServiceDefaults", "RecNet.ServiceDefaults\RecNet.ServiceDefaults.csproj", "{7773AA04-37C6-4E72-98AB-A239ED268ECC}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.ServiceDefaults", "src\RecNet.ServiceDefaults\RecNet.ServiceDefaults.csproj", "{7773AA04-37C6-4E72-98AB-A239ED268ECC}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHost", "AppHost\AppHost.csproj", "{F539C6BB-F396-41CC-B275-DF8CC3B8CA2F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHost", "src\AppHost\AppHost.csproj", "{F539C6BB-F396-41CC-B275-DF8CC3B8CA2F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "API\API.csproj", "{CD6E60F3-675A-4F51-8645-9CA6B35C1032}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "src\API\API.csproj", "{CD6E60F3-675A-4F51-8645-9CA6B35C1032}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.Infrastructure", "RecNet.Infrastructure\RecNet.Infrastructure.csproj", "{E61153A9-DAD9-4ED3-A8A5-8F619BBE54D4}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.Infrastructure", "src\RecNet.Infrastructure\RecNet.Infrastructure.csproj", "{E61153A9-DAD9-4ED3-A8A5-8F619BBE54D4}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.Domain", "RecNet.Domain\RecNet.Domain.csproj", "{4E9D18A6-BC68-49BE-81FE-03B74270485D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.Domain", "src\RecNet.Domain\RecNet.Domain.csproj", "{4E9D18A6-BC68-49BE-81FE-03B74270485D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.Application", "RecNet.Application\RecNet.Application.csproj", "{BF255F63-3A85-4AD4-AB13-1C1C1C1724ED}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.Application", "src\RecNet.Application\RecNet.Application.csproj", "{BF255F63-3A85-4AD4-AB13-1C1C1C1724ED}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.MigrationService", "RecNet.MigrationService\RecNet.MigrationService.csproj", "{2343DEEB-8CBA-4B0A-BE67-3F8F76E6E7C1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RecNet.MigrationService", "src\RecNet.MigrationService\RecNet.MigrationService.csproj", "{2343DEEB-8CBA-4B0A-BE67-3F8F76E6E7C1}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@@ -0,0 +1,7 @@
namespace API.Configuration;
public class NeutrinoOptions
{
public string Secret { get; set; } = string.Empty;
public bool ValidateSecret { get; set; } = false;
}

View File

@@ -1,21 +1,31 @@
using System.Text.Json; using System.Text.Json;
using API.Configuration;
using API.Contracts.Neutrino.Enums; using API.Contracts.Neutrino.Enums;
using API.Contracts.Neutrino.Requests; using API.Contracts.Neutrino.Requests;
using API.Contracts.Neutrino.Responses; using API.Contracts.Neutrino.Responses;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using RecNet.Application.Neutrino; using RecNet.Application.Neutrino;
namespace API.Controllers.Neutrino; namespace API.Controllers.Neutrino;
[Route("[controller]")] [Route("[controller]")]
[ApiController] [ApiController]
public class NeutrinoController(INeutrinoAuthorizationService authorizationService) : ControllerBase public class NeutrinoController(
INeutrinoAuthorizationService authorizationService,
IOptions<NeutrinoOptions> options) : ControllerBase
{ {
private readonly NeutrinoOptions _options = options.Value;
// Photon sends the request with Content-Type: text/plain instead of application/json. // Photon sends the request with Content-Type: text/plain instead of application/json.
[Route("authorize")] [Route("authorize")]
public async Task<ActionResult<NeutrinoAuthenticateResponse>> AuthorizeNeutrinoAsync( public async Task<ActionResult<NeutrinoAuthenticateResponse>> AuthorizeNeutrinoAsync(
CancellationToken ct) [FromQuery(Name = "secret")] string? secret = null,
CancellationToken ct = default)
{ {
if (_options.ValidateSecret && secret != _options.Secret)
return Forbid();
using var reader = new StreamReader(Request.Body); using var reader = new StreamReader(Request.Body);
string rawText = await reader.ReadToEndAsync(ct); string rawText = await reader.ReadToEndAsync(ct);

View File

@@ -15,6 +15,11 @@ public class Program
public static void Main(string[] args) public static void Main(string[] args)
{ {
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddOptions<NeutrinoOptions>()
.Bind(builder.Configuration.GetSection("Neutrino"))
.ValidateOnStart();
var recNetOptions = builder.Configuration.GetSection("RecNet").Get<RecNetOptions>() var recNetOptions = builder.Configuration.GetSection("RecNet").Get<RecNetOptions>()
?? new RecNetOptions(); ?? new RecNetOptions();

View File

@@ -38,7 +38,7 @@ public static class DependencyInjection
builder.Services.AddScoped<IPlatformAuthValidator, SteamAuthValidator>(); builder.Services.AddScoped<IPlatformAuthValidator, SteamAuthValidator>();
builder.Services.AddScoped<IPlatformAuthValidator, MetaAuthValidator>(); builder.Services.AddScoped<IPlatformAuthValidator, MetaAuthValidator>();
builder.Services.AddScoped<IGameVersionRepository, IGameVersionRepository>(); builder.Services.AddScoped<IGameVersionRepository, GameVersionRepository>();
builder.Services.AddScoped<IProfileRepository, ProfileRepository>(); builder.Services.AddScoped<IProfileRepository, ProfileRepository>();
builder.Services.AddScoped<IServerConfigRepository, ServerConfigRepository>(); builder.Services.AddScoped<IServerConfigRepository, ServerConfigRepository>();