Add Meta authentication secret and SHA256 hashing

This commit is contained in:
Holden
2026-06-21 15:36:17 -05:00
parent e77e479493
commit 706c4f13d8
7 changed files with 242 additions and 8 deletions

View File

@@ -1,5 +1,7 @@
using AutoMapper;
using RecNet.Application.Common.Interfaces;
using RecNet.Application.Common.Security;
using RecNet.Domain.Common;
using RecNet.Domain.GameVersions;
using RecNet.Domain.Profiles;
using ProfileEntity = RecNet.Domain.Profiles.Profile;
@@ -51,7 +53,7 @@ public class ProfileService(
);
await profileRepository.SaveChangesAsync(ct);
return mapper.Map<AvatarDTO>(profile.Avatar);
}
@@ -60,13 +62,13 @@ public class ProfileService(
CancellationToken ct = default)
{
var settings = await profileRepository.GetSettingsByProfileIdAsync(profileId, ct);
return mapper.Map<List<PlayerSettingDTO>>(settings);
}
public async Task<bool> UpdatePlayerSettingAsync(
Guid profileId,
UpdatePlayerSettingCommand command,
Guid profileId,
UpdatePlayerSettingCommand command,
CancellationToken ct = default)
{
var profile = await profileRepository.GetByIdWithSettingsAsync(profileId, ct);
@@ -130,9 +132,15 @@ public class ProfileService(
command.PlatformType,
command.PlatformId);
if (command.PlatformType == PlatformType.Meta)
profile.SetMetaAuthenticationSecret(Hashing.ComputeSha256(command.PlatformAuthentication));
await profileRepository.AddAsync(profile, ct);
}
if (command.PlatformType == PlatformType.Meta && !Hashing.VerifySha256(command.PlatformAuthentication, profile.MetaAuthenticationSecret))
return LoginProfileResult.Fail("Platform Auth Failed: Invalid authentication");
if (profile.IsBanned)
return LoginProfileResult.Fail("Profile is banned");
@@ -148,4 +156,4 @@ public class ProfileService(
expiresIn: token.ExpiresIn
);
}
}
}