Add Steam auth, platform validators & name gen

This commit is contained in:
Holden
2026-06-19 14:48:19 -05:00
parent 0b81cb046a
commit 63730dbba0
24 changed files with 592 additions and 17 deletions

View File

@@ -0,0 +1,48 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using RecNet.Application.Common.Interfaces;
using RecNet.Application.Common.PlatformAuth;
using RecNet.Domain.Common;
namespace RecNet.Infrastructure.Services.Steam;
public class SteamAuthValidator(ISteamAuthService steamAuthService) : IPlatformAuthValidator
{
public PlatformType PlatformType
=> PlatformType.Steamworks;
public async Task<PlatformAuthResult> ValidateAsync(
string platformAuthentication,
string platformId,
CancellationToken ct = default)
{
var steamParams = JsonSerializer.Deserialize<SteamPlatformAuth>(platformAuthentication);
if (steamParams == null)
return PlatformAuthResult.Failure("Invalid authentication");
var result = await steamAuthService.AuthorizeAsync(steamParams.Ticket, steamParams.AppId.AppId, ct);
if (!result.Succeeded || result.SteamId is null)
return PlatformAuthResult.Failure("Invalid authentication");
if (!string.IsNullOrWhiteSpace(platformId) &&
platformId != result.SteamId)
return PlatformAuthResult.Failure("Nice try");
return PlatformAuthResult.Success(result.DisplayName);
}
private sealed class SteamPlatformAuth
{
public required string Ticket { get; set; }
public required SteamAppIdAuth AppId { get; set; }
}
// Splooty, why did you set it up like this ;-;
private sealed class SteamAppIdAuth
{
[JsonPropertyName("m_AppId")]
public required uint AppId { get; set; }
}
}