Move projects to src; add Neutrino secret
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
namespace RecNet.Application.Common.Interfaces;
|
||||
|
||||
public interface IConfigService
|
||||
{
|
||||
Task<T?> GetAsync<T>(string key, CancellationToken ct = default);
|
||||
Task<T> GetAsync<T>(string key, T defaultValue, CancellationToken ct = default);
|
||||
Task SetAsync<T>(string key, T value, CancellationToken ct = default);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using RecNet.Application.Common.PlatformAuth;
|
||||
using RecNet.Domain.Common;
|
||||
|
||||
namespace RecNet.Application.Common.Interfaces;
|
||||
|
||||
public interface IPlatformAuthValidator
|
||||
{
|
||||
PlatformType PlatformType { get; }
|
||||
|
||||
Task<PlatformAuthResult> ValidateAsync(
|
||||
string platformAuthentication,
|
||||
string platformId,
|
||||
CancellationToken ct = default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using RecNet.Application.Common.Steam;
|
||||
|
||||
namespace RecNet.Application.Common.Interfaces;
|
||||
|
||||
public interface ISteamAuthService
|
||||
{
|
||||
Task<SteamAuthResult> AuthorizeAsync(
|
||||
string ticket,
|
||||
uint appId,
|
||||
CancellationToken ct = default);
|
||||
}
|
||||
10
src/RecNet.Application/Common/Interfaces/ITokenService.cs
Normal file
10
src/RecNet.Application/Common/Interfaces/ITokenService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using RecNet.Application.Common.Tokens;
|
||||
using RecNet.Domain.Profiles;
|
||||
|
||||
namespace RecNet.Application.Common.Interfaces;
|
||||
|
||||
public interface ITokenService
|
||||
{
|
||||
TokenResult GenerateProfileToken(Profile profile);
|
||||
TokenVerifyResult VerifyToken(string token);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using AutoMapper;
|
||||
using RecNet.Application.Profiles;
|
||||
|
||||
namespace RecNet.Application.Common.Mapping;
|
||||
|
||||
public class ApplicationMappingProfile : Profile
|
||||
{
|
||||
public ApplicationMappingProfile()
|
||||
{
|
||||
CreateMap<Domain.Profiles.Profile, ProfileDTO>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace RecNet.Application.Common.PlatformAuth;
|
||||
|
||||
public class PlatformAuthResult
|
||||
{
|
||||
public bool Succeeded { get; private set; }
|
||||
public string? Message { get; private set; }
|
||||
public string? Name { get; private set; }
|
||||
|
||||
private PlatformAuthResult(bool succeeded, string? message, string? name)
|
||||
{
|
||||
Succeeded = succeeded;
|
||||
Message = message;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public static PlatformAuthResult Success(string? name)
|
||||
=> new(true, null, name);
|
||||
|
||||
public static PlatformAuthResult Failure(string? message = null)
|
||||
=> new(false, message, null);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace RecNet.Application.Common.Security;
|
||||
|
||||
public static class ClaimsPrincipalExtensions
|
||||
{
|
||||
public static Guid GetProfileId(this ClaimsPrincipal user)
|
||||
{
|
||||
var value =
|
||||
user.FindFirst("sub")?.Value ??
|
||||
user.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
if (!Guid.TryParse(value, out var profileId))
|
||||
throw new UnauthorizedAccessException(
|
||||
"Account id claim is missing or invalid.");
|
||||
|
||||
return profileId;
|
||||
}
|
||||
}
|
||||
21
src/RecNet.Application/Common/Steam/SteamAuthResult.cs
Normal file
21
src/RecNet.Application/Common/Steam/SteamAuthResult.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace RecNet.Application.Common.Steam;
|
||||
|
||||
public class SteamAuthResult
|
||||
{
|
||||
public bool Succeeded { get; private set; }
|
||||
public string? SteamId { get; private set; }
|
||||
public string? DisplayName { get; private set; }
|
||||
|
||||
private SteamAuthResult(bool succeeded, string? steamId, string? displayName)
|
||||
{
|
||||
Succeeded = succeeded;
|
||||
SteamId = steamId;
|
||||
DisplayName = displayName;
|
||||
}
|
||||
|
||||
public static SteamAuthResult Success(string steamId, string? displayName)
|
||||
=> new(true, steamId, displayName);
|
||||
|
||||
public static SteamAuthResult Failure()
|
||||
=> new (false, null, null);
|
||||
}
|
||||
5
src/RecNet.Application/Common/Tokens/TokenResult.cs
Normal file
5
src/RecNet.Application/Common/Tokens/TokenResult.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace RecNet.Application.Common.Tokens;
|
||||
|
||||
public sealed record TokenResult(
|
||||
string AccessToken,
|
||||
int ExpiresIn);
|
||||
12
src/RecNet.Application/Common/Tokens/TokenVerifyResult.cs
Normal file
12
src/RecNet.Application/Common/Tokens/TokenVerifyResult.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace RecNet.Application.Common.Tokens;
|
||||
|
||||
public sealed record TokenVerifyResult(
|
||||
bool Succeeded,
|
||||
Guid? ProfileId)
|
||||
{
|
||||
public static TokenVerifyResult Success(Guid profileId)
|
||||
=> new(true, profileId);
|
||||
|
||||
public static TokenVerifyResult Failure()
|
||||
=> new(false, null);
|
||||
}
|
||||
Reference in New Issue
Block a user