add EF core db migrations, add banned + forbidden uploads db entries, adjust authentication to include characternamehash to check for bans, prepare for message sending from client to other clients
This commit is contained in:
@@ -7,5 +7,6 @@
|
||||
public bool IsSynced { get; set; }
|
||||
public bool IsPausedFromOthers { get; set; }
|
||||
public bool IsRemoved { get; set; }
|
||||
public bool AllowReceiveMessages { get; set; }
|
||||
}
|
||||
}
|
||||
17
MareSynchronosServer/MareSynchronos.API/DownloadFileDto.cs
Normal file
17
MareSynchronosServer/MareSynchronos.API/DownloadFileDto.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public class DownloadFileDto
|
||||
{
|
||||
public bool FileExists { get; set; } = true;
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
public long Size { get; set; } = 0;
|
||||
public bool IsForbidden { get; set; } = false;
|
||||
public string ForbiddenBy { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
15
MareSynchronosServer/MareSynchronos.API/UploadFileDto.cs
Normal file
15
MareSynchronosServer/MareSynchronos.API/UploadFileDto.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MareSynchronos.API
|
||||
{
|
||||
public class UploadFileDto
|
||||
{
|
||||
public string Hash { get; set; } = string.Empty;
|
||||
public bool IsForbidden { get; set; } = false;
|
||||
public string ForbiddenBy { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -8,26 +8,26 @@ using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronosServer.Data;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace MareSynchronosServer.Authentication
|
||||
{
|
||||
public class SecretKeyAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||
{
|
||||
private readonly MareDbContext _mareDbContext;
|
||||
public const string AUTH_SCHEME = "SecretKeyAuth";
|
||||
public const string AuthScheme = "SecretKeyAuth";
|
||||
|
||||
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
{
|
||||
if (!Request.Headers.ContainsKey("Authorization"))
|
||||
return Task.FromResult(AuthenticateResult.Fail("Failed Authorization"));
|
||||
return AuthenticateResult.Fail("Failed Authorization");
|
||||
|
||||
var authHeader = Request.Headers["Authorization"].ToString();
|
||||
|
||||
if (string.IsNullOrEmpty(authHeader))
|
||||
return Task.FromResult(AuthenticateResult.Fail("Failed Authorization"));
|
||||
return AuthenticateResult.Fail("Failed Authorization");
|
||||
|
||||
using var sha256 = SHA256.Create();
|
||||
var hashedHeader = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(authHeader))).Replace("-", "");
|
||||
@@ -35,11 +35,27 @@ namespace MareSynchronosServer.Authentication
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
return Task.FromResult(AuthenticateResult.Fail("Failed Authorization"));
|
||||
return AuthenticateResult.Fail("Failed Authorization");
|
||||
}
|
||||
|
||||
var charNameHeader = Request.Headers["CharacterNameHash"].ToString();
|
||||
|
||||
if (string.IsNullOrEmpty(charNameHeader) || charNameHeader == "--")
|
||||
return AuthenticateResult.Fail("Requires CharacterNameHash");
|
||||
|
||||
var isBanned = await _mareDbContext.BannedUsers.AnyAsync(u => u.CharacterIdentification == charNameHeader);
|
||||
|
||||
if (isBanned)
|
||||
{
|
||||
return AuthenticateResult.Fail("Banned");
|
||||
}
|
||||
|
||||
user.CharacterIdentification = charNameHeader;
|
||||
_mareDbContext.Users.Update(user);
|
||||
await _mareDbContext.SaveChangesAsync();
|
||||
|
||||
var claims = new List<Claim> {
|
||||
new Claim(ClaimTypes.Name, user.CharacterIdentification ?? "Unknown"),
|
||||
new Claim(ClaimTypes.Name, user.CharacterIdentification),
|
||||
new Claim(ClaimTypes.NameIdentifier, user.UID)
|
||||
};
|
||||
|
||||
@@ -47,7 +63,7 @@ namespace MareSynchronosServer.Authentication
|
||||
var principal = new ClaimsPrincipal(identity);
|
||||
var ticket = new AuthenticationTicket(principal, this.Scheme.Name);
|
||||
|
||||
return Task.FromResult(AuthenticateResult.Success(ticket));
|
||||
return AuthenticateResult.Success(ticket);
|
||||
}
|
||||
|
||||
public SecretKeyAuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, MareDbContext mareDbContext) : base(options, logger, encoder, clock)
|
||||
|
||||
@@ -6,7 +6,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace MareSynchronosServer.Data
|
||||
{
|
||||
public class MareDbContext : Microsoft.EntityFrameworkCore.DbContext
|
||||
public class MareDbContext : DbContext
|
||||
{
|
||||
public MareDbContext(DbContextOptions<MareDbContext> options) : base(options)
|
||||
{
|
||||
@@ -16,6 +16,9 @@ namespace MareSynchronosServer.Data
|
||||
public DbSet<FileCache> Files { get; set; }
|
||||
public DbSet<ClientPair> ClientPairs { get; set; }
|
||||
public DbSet<CharacterData> CharacterData { get; set; }
|
||||
public DbSet<ForbiddenUploadEntry> ForbiddenUploadEntries { get; set; }
|
||||
public DbSet<Banned> BannedUsers { get; set; }
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -30,6 +33,8 @@ namespace MareSynchronosServer.Data
|
||||
modelBuilder.Entity<CharacterData>()
|
||||
.ToTable("CharacterData")
|
||||
.HasKey(k => new { k.UserId, k.JobId });
|
||||
modelBuilder.Entity<ForbiddenUploadEntry>().ToTable("ForbiddenUploadEntries");
|
||||
modelBuilder.Entity<Banned>().ToTable("BannedUsers");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using MareSynchronos.API;
|
||||
using MareSynchronosServer.Authentication;
|
||||
using MareSynchronosServer.Data;
|
||||
using MareSynchronosServer.Models;
|
||||
@@ -31,7 +29,7 @@ namespace MareSynchronosServer.Hubs
|
||||
|
||||
private string BasePath => _configuration["CacheDirectory"];
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task AbortUpload()
|
||||
{
|
||||
Logger.LogInformation("User " + AuthenticatedUserId + " aborted upload");
|
||||
@@ -41,15 +39,22 @@ namespace MareSynchronosServer.Hubs
|
||||
await DbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
public async Task<List<string>> SendFiles(List<string> fileListHashes)
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task<List<UploadFileDto>> SendFiles(List<string> fileListHashes)
|
||||
{
|
||||
Logger.LogInformation("User " + AuthenticatedUserId + " sending files");
|
||||
List<string> filesToUpload = new List<string>();
|
||||
var existingFiles = DbContext.Files.Where(f => fileListHashes.Contains(f.Hash)).ToList();
|
||||
foreach (var file in fileListHashes.Where(f => existingFiles.All(e => e.Hash != f)))
|
||||
var forbiddenFiles = DbContext.ForbiddenUploadEntries.Where(f => fileListHashes.Contains(f.Hash));
|
||||
var filesToUpload = new List<UploadFileDto>();
|
||||
filesToUpload.AddRange(forbiddenFiles.Select(f => new UploadFileDto()
|
||||
{
|
||||
Debug.WriteLine("File: " + file);
|
||||
ForbiddenBy = f.ForbiddenBy,
|
||||
Hash = f.Hash,
|
||||
IsForbidden = true
|
||||
}));
|
||||
var existingFiles = DbContext.Files.Where(f => fileListHashes.Contains(f.Hash)).ToList();
|
||||
foreach (var file in fileListHashes.Where(f => existingFiles.All(e => e.Hash != f) && filesToUpload.All(u => u.Hash != f)))
|
||||
{
|
||||
Logger.LogInformation("Needs upload: " + file);
|
||||
var userId = AuthenticatedUserId;
|
||||
await DbContext.Files.AddAsync(new FileCache()
|
||||
{
|
||||
@@ -59,26 +64,31 @@ namespace MareSynchronosServer.Hubs
|
||||
Uploader = DbContext.Users.Single(u => u.UID == userId)
|
||||
});
|
||||
await DbContext.SaveChangesAsync();
|
||||
filesToUpload.Add(file);
|
||||
filesToUpload.Add(new UploadFileDto
|
||||
{
|
||||
Hash = file
|
||||
});
|
||||
}
|
||||
|
||||
return filesToUpload;
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task<bool> IsUploadFinished()
|
||||
{
|
||||
var userUid = AuthenticatedUserId;
|
||||
return await DbContext.Files.AnyAsync(f => f.Uploader.UID == userUid && !f.Uploaded);
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task UploadFileStreamAsync(string hash, IAsyncEnumerable<byte[]> fileContent)
|
||||
{
|
||||
Logger.LogInformation("User " + AuthenticatedUserId + " uploading file: " + hash);
|
||||
|
||||
var relatedFile = DbContext.Files.SingleOrDefault(f => f.Hash == hash && f.Uploader.UID == AuthenticatedUserId && f.Uploaded == false);
|
||||
if (relatedFile == null) return;
|
||||
var forbiddenFile = DbContext.ForbiddenUploadEntries.SingleOrDefault(f => f.Hash == hash);
|
||||
if (forbiddenFile != null) return;
|
||||
var uploadedFile = new List<byte>();
|
||||
await foreach (var chunk in fileContent)
|
||||
{
|
||||
@@ -113,20 +123,33 @@ namespace MareSynchronosServer.Hubs
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
public async Task<long> GetFileSize(string hash)
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task<DownloadFileDto> GetFileSize(string hash)
|
||||
{
|
||||
var file = await DbContext.Files.SingleOrDefaultAsync(f => f.Hash == hash);
|
||||
if (file == null) return -1;
|
||||
var forbidden = DbContext.ForbiddenUploadEntries.SingleOrDefault(f => f.Hash == hash);
|
||||
var fileInfo = new FileInfo(Path.Combine(BasePath, hash));
|
||||
if (fileInfo.Exists) return fileInfo.Length;
|
||||
DbContext.Files.Remove(file);
|
||||
await DbContext.SaveChangesAsync();
|
||||
return -1;
|
||||
|
||||
var response = new DownloadFileDto
|
||||
{
|
||||
FileExists = file != null,
|
||||
ForbiddenBy = forbidden?.ForbiddenBy ?? string.Empty,
|
||||
IsForbidden = forbidden != null,
|
||||
Hash = hash,
|
||||
Size = fileInfo.Length
|
||||
};
|
||||
|
||||
if (!fileInfo.Exists && file != null)
|
||||
{
|
||||
DbContext.Files.Remove(file);
|
||||
await DbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async IAsyncEnumerable<byte[]> DownloadFileAsync(string hash, [EnumeratorCancellation] CancellationToken ct)
|
||||
{
|
||||
Logger.LogInformation("User " + AuthenticatedUserId + " downloading file: " + hash);
|
||||
@@ -150,7 +173,7 @@ namespace MareSynchronosServer.Hubs
|
||||
Logger.LogInformation("User " + AuthenticatedUserId + " finished downloading file: " + hash);
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task DeleteAllFiles()
|
||||
{
|
||||
Logger.LogInformation("User " + AuthenticatedUserId + " deleted all their files");
|
||||
@@ -160,7 +183,7 @@ namespace MareSynchronosServer.Hubs
|
||||
var ownFiles = await DbContext.Files.Where(f => f.Uploaded && f.Uploader.UID == AuthenticatedUserId).ToListAsync();
|
||||
foreach (var file in ownFiles)
|
||||
{
|
||||
File.Delete(Path.Combine(BasePath, file.Hash));
|
||||
File.Delete(Path.Combine(BasePath, file.Hash));
|
||||
}
|
||||
DbContext.Files.RemoveRange(ownFiles);
|
||||
await DbContext.SaveChangesAsync();
|
||||
|
||||
@@ -56,13 +56,13 @@ namespace MareSynchronosServer.Hubs
|
||||
private ClientPair OppositeEntry(string otherUID) =>
|
||||
DbContext.ClientPairs.SingleOrDefault(w => w.User.UID == otherUID && w.OtherUser.UID == AuthenticatedUserId);
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public string GetUID()
|
||||
{
|
||||
return AuthenticatedUserId;
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task GetCharacterData(Dictionary<string, int> visibleCharacterWithJobs)
|
||||
{
|
||||
var uid = AuthenticatedUserId;
|
||||
@@ -89,7 +89,7 @@ namespace MareSynchronosServer.Hubs
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task PushCharacterData(CharacterCacheDto characterCache, List<string> visibleCharacterIds)
|
||||
{
|
||||
Logger.LogInformation("User " + AuthenticatedUserId + " pushing character data");
|
||||
@@ -134,14 +134,12 @@ namespace MareSynchronosServer.Hubs
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
public async Task<List<string>> SendCharacterNameHash(string characterNameHash)
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task<List<string>> GetOnlineCharacters()
|
||||
{
|
||||
Logger.LogInformation("User " + AuthenticatedUserId + " sent character hash");
|
||||
|
||||
var ownUser = DbContext.Users.Single(u => u.UID == AuthenticatedUserId);
|
||||
ownUser.CharacterIdentification = characterNameHash;
|
||||
await DbContext.SaveChangesAsync();
|
||||
var otherUsers = await DbContext.ClientPairs
|
||||
.Include(u => u.User)
|
||||
.Include(u => u.OtherUser)
|
||||
@@ -151,13 +149,13 @@ namespace MareSynchronosServer.Hubs
|
||||
var otherEntries = await DbContext.ClientPairs.Include(u => u.User)
|
||||
.Where(u => otherUsers.Any(e => e == u.User) && u.OtherUser == ownUser && !u.IsPaused).ToListAsync();
|
||||
|
||||
await Clients.Users(otherEntries.Select(e => e.User.UID)).SendAsync("AddOnlinePairedPlayer", characterNameHash);
|
||||
await Clients.Users(otherEntries.Select(e => e.User.UID)).SendAsync("AddOnlinePairedPlayer", ownUser.CharacterIdentification);
|
||||
await Clients.All.SendAsync("UsersOnline",
|
||||
await DbContext.Users.CountAsync(u => !string.IsNullOrEmpty(u.CharacterIdentification)));
|
||||
return otherEntries.Select(e => e.User.CharacterIdentification).ToList();
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task SendPairedClientAddition(string uid)
|
||||
{
|
||||
if (uid == AuthenticatedUserId) return;
|
||||
@@ -207,7 +205,7 @@ namespace MareSynchronosServer.Hubs
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task SendPairedClientRemoval(string uid)
|
||||
{
|
||||
if (uid == AuthenticatedUserId) return;
|
||||
@@ -247,7 +245,7 @@ namespace MareSynchronosServer.Hubs
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task SendPairedClientPauseChange(string uid, bool isPaused)
|
||||
{
|
||||
if (uid == AuthenticatedUserId) return;
|
||||
@@ -282,7 +280,7 @@ namespace MareSynchronosServer.Hubs
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task<List<ClientPairDto>> GetPairedClients()
|
||||
{
|
||||
string userid = AuthenticatedUserId;
|
||||
@@ -305,7 +303,7 @@ namespace MareSynchronosServer.Hubs
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AUTH_SCHEME)]
|
||||
[Authorize(AuthenticationSchemes = SecretKeyAuthenticationHandler.AuthScheme)]
|
||||
public async Task DeleteAccount()
|
||||
{
|
||||
Logger.LogInformation("User " + AuthenticatedUserId + " deleted their account");
|
||||
|
||||
@@ -8,18 +8,17 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bazinga.AspNetCore.Authentication.Basic" Version="2.0.1" />
|
||||
<PackageReference Include="lz4net" Version="1.0.15.93" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.17" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.17" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="5.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.17" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.6">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="IDProvider\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MareSynchronos.API\MareSynchronos.API.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
150
MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.Designer.cs
generated
Normal file
150
MareSynchronosServer/MareSynchronosServer/Migrations/20220629173313_InitialCreate.Designer.cs
generated
Normal file
@@ -0,0 +1,150 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MareSynchronosServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(MareDbContext))]
|
||||
[Migration("20220629173313_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.CharacterData", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("JobId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("CharacterCache")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("UserId", "JobId");
|
||||
|
||||
b.ToTable("CharacterData", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<bool>("IsPaused")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("OtherUserUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.Property<string>("UserUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OtherUserUID");
|
||||
|
||||
b.HasIndex("UserUID");
|
||||
|
||||
b.ToTable("ClientPairs", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b =>
|
||||
{
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<DateTime>("LastAccessTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.Property<bool>("Uploaded")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("UploaderUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("Hash");
|
||||
|
||||
b.HasIndex("UploaderUID");
|
||||
|
||||
b.ToTable("FileCaches", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.User", b =>
|
||||
{
|
||||
b.Property<string>("UID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("CharacterIdentification")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SecretKey")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.HasKey("UID");
|
||||
|
||||
b.ToTable("Users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosServer.Models.User", "OtherUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("OtherUserUID");
|
||||
|
||||
b.HasOne("MareSynchronosServer.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID");
|
||||
|
||||
b.Navigation("OtherUser");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosServer.Models.User", "Uploader")
|
||||
.WithMany()
|
||||
.HasForeignKey("UploaderUID");
|
||||
|
||||
b.Navigation("Uploader");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CharacterData",
|
||||
columns: table => new
|
||||
{
|
||||
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
JobId = table.Column<int>(type: "int", nullable: false),
|
||||
CharacterCache = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Hash = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CharacterData", x => new { x.UserId, x.JobId });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
UID = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
SecretKey = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
CharacterIdentification = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Timestamp = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.UID);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ClientPairs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
UserUID = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
||||
OtherUserUID = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
||||
IsPaused = table.Column<bool>(type: "bit", nullable: false),
|
||||
Timestamp = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ClientPairs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ClientPairs_Users_OtherUserUID",
|
||||
column: x => x.OtherUserUID,
|
||||
principalTable: "Users",
|
||||
principalColumn: "UID");
|
||||
table.ForeignKey(
|
||||
name: "FK_ClientPairs_Users_UserUID",
|
||||
column: x => x.UserUID,
|
||||
principalTable: "Users",
|
||||
principalColumn: "UID");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FileCaches",
|
||||
columns: table => new
|
||||
{
|
||||
Hash = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
UploaderUID = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
||||
Uploaded = table.Column<bool>(type: "bit", nullable: false),
|
||||
LastAccessTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Timestamp = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FileCaches", x => x.Hash);
|
||||
table.ForeignKey(
|
||||
name: "FK_FileCaches_Users_UploaderUID",
|
||||
column: x => x.UploaderUID,
|
||||
principalTable: "Users",
|
||||
principalColumn: "UID");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ClientPairs_OtherUserUID",
|
||||
table: "ClientPairs",
|
||||
column: "OtherUserUID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ClientPairs_UserUID",
|
||||
table: "ClientPairs",
|
||||
column: "UserUID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FileCaches_UploaderUID",
|
||||
table: "FileCaches",
|
||||
column: "UploaderUID");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CharacterData");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ClientPairs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "FileCaches");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
}
|
||||
}
|
||||
}
|
||||
163
MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.Designer.cs
generated
Normal file
163
MareSynchronosServer/MareSynchronosServer/Migrations/20220629173544_AddForbiddenUploadEntry.Designer.cs
generated
Normal file
@@ -0,0 +1,163 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MareSynchronosServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(MareDbContext))]
|
||||
[Migration("20220629173544_AddForbiddenUploadEntry")]
|
||||
partial class AddForbiddenUploadEntry
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.CharacterData", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("JobId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("CharacterCache")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("UserId", "JobId");
|
||||
|
||||
b.ToTable("CharacterData", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<bool>("IsPaused")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("OtherUserUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.Property<string>("UserUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OtherUserUID");
|
||||
|
||||
b.HasIndex("UserUID");
|
||||
|
||||
b.ToTable("ClientPairs", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b =>
|
||||
{
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<DateTime>("LastAccessTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.Property<bool>("Uploaded")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("UploaderUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("Hash");
|
||||
|
||||
b.HasIndex("UploaderUID");
|
||||
|
||||
b.ToTable("FileCaches", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b =>
|
||||
{
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("ForbiddenBy")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Hash");
|
||||
|
||||
b.ToTable("ForbiddenUploadEntries", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.User", b =>
|
||||
{
|
||||
b.Property<string>("UID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("CharacterIdentification")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SecretKey")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.HasKey("UID");
|
||||
|
||||
b.ToTable("Users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosServer.Models.User", "OtherUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("OtherUserUID");
|
||||
|
||||
b.HasOne("MareSynchronosServer.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID");
|
||||
|
||||
b.Navigation("OtherUser");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosServer.Models.User", "Uploader")
|
||||
.WithMany()
|
||||
.HasForeignKey("UploaderUID");
|
||||
|
||||
b.Navigation("Uploader");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
public partial class AddForbiddenUploadEntry : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ForbiddenUploadEntries",
|
||||
columns: table => new
|
||||
{
|
||||
Hash = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
ForbiddenBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ForbiddenUploadEntries", x => x.Hash);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ForbiddenUploadEntries");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MareSynchronosServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(MareDbContext))]
|
||||
[Migration("20220629184351_AddBannedAdminAndReceivingMessages")]
|
||||
partial class AddBannedAdminAndReceivingMessages
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.Banned", b =>
|
||||
{
|
||||
b.Property<string>("CharacterIdentification")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("CharacterIdentification");
|
||||
|
||||
b.ToTable("BannedUsers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.CharacterData", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("JobId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("CharacterCache")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("UserId", "JobId");
|
||||
|
||||
b.ToTable("CharacterData", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<bool>("AllowReceivingMessages")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsPaused")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("OtherUserUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.Property<string>("UserUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OtherUserUID");
|
||||
|
||||
b.HasIndex("UserUID");
|
||||
|
||||
b.ToTable("ClientPairs", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b =>
|
||||
{
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<DateTime>("LastAccessTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.Property<bool>("Uploaded")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("UploaderUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("Hash");
|
||||
|
||||
b.HasIndex("UploaderUID");
|
||||
|
||||
b.ToTable("FileCaches", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b =>
|
||||
{
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("ForbiddenBy")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Hash");
|
||||
|
||||
b.ToTable("ForbiddenUploadEntries", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.User", b =>
|
||||
{
|
||||
b.Property<string>("UID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("CharacterIdentification")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("IsAdmin")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("SecretKey")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.HasKey("UID");
|
||||
|
||||
b.ToTable("Users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosServer.Models.User", "OtherUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("OtherUserUID");
|
||||
|
||||
b.HasOne("MareSynchronosServer.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID");
|
||||
|
||||
b.Navigation("OtherUser");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosServer.Models.User", "Uploader")
|
||||
.WithMany()
|
||||
.HasForeignKey("UploaderUID");
|
||||
|
||||
b.Navigation("Uploader");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
public partial class AddBannedAdminAndReceivingMessages : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsAdmin",
|
||||
table: "Users",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "AllowReceivingMessages",
|
||||
table: "ClientPairs",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "BannedUsers",
|
||||
columns: table => new
|
||||
{
|
||||
CharacterIdentification = table.Column<string>(type: "nvarchar(450)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_BannedUsers", x => x.CharacterIdentification);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "BannedUsers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsAdmin",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AllowReceivingMessages",
|
||||
table: "ClientPairs");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MareSynchronosServer.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(MareDbContext))]
|
||||
partial class MareDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.Banned", b =>
|
||||
{
|
||||
b.Property<string>("CharacterIdentification")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("CharacterIdentification");
|
||||
|
||||
b.ToTable("BannedUsers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.CharacterData", b =>
|
||||
{
|
||||
b.Property<string>("UserId")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int>("JobId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("CharacterCache")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("UserId", "JobId");
|
||||
|
||||
b.ToTable("CharacterData", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
|
||||
|
||||
b.Property<bool>("AllowReceivingMessages")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<bool>("IsPaused")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("OtherUserUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.Property<string>("UserUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OtherUserUID");
|
||||
|
||||
b.HasIndex("UserUID");
|
||||
|
||||
b.ToTable("ClientPairs", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b =>
|
||||
{
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<DateTime>("LastAccessTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.Property<bool>("Uploaded")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("UploaderUID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.HasKey("Hash");
|
||||
|
||||
b.HasIndex("UploaderUID");
|
||||
|
||||
b.ToTable("FileCaches", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ForbiddenUploadEntry", b =>
|
||||
{
|
||||
b.Property<string>("Hash")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("ForbiddenBy")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Hash");
|
||||
|
||||
b.ToTable("ForbiddenUploadEntries", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.User", b =>
|
||||
{
|
||||
b.Property<string>("UID")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("CharacterIdentification")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<bool>("IsAdmin")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<string>("SecretKey")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<byte[]>("Timestamp")
|
||||
.IsConcurrencyToken()
|
||||
.ValueGeneratedOnAddOrUpdate()
|
||||
.HasColumnType("rowversion");
|
||||
|
||||
b.HasKey("UID");
|
||||
|
||||
b.ToTable("Users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.ClientPair", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosServer.Models.User", "OtherUser")
|
||||
.WithMany()
|
||||
.HasForeignKey("OtherUserUID");
|
||||
|
||||
b.HasOne("MareSynchronosServer.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID");
|
||||
|
||||
b.Navigation("OtherUser");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosServer.Models.FileCache", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosServer.Models.User", "Uploader")
|
||||
.WithMany()
|
||||
.HasForeignKey("UploaderUID");
|
||||
|
||||
b.Navigation("Uploader");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
10
MareSynchronosServer/MareSynchronosServer/Models/Banned.cs
Normal file
10
MareSynchronosServer/MareSynchronosServer/Models/Banned.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MareSynchronosServer.Models
|
||||
{
|
||||
public class Banned
|
||||
{
|
||||
[Key]
|
||||
public string CharacterIdentification { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ namespace MareSynchronosServer.Models
|
||||
public User User { get; set; }
|
||||
public User OtherUser { get; set; }
|
||||
public bool IsPaused { get; set; }
|
||||
public bool AllowReceivingMessages { get; set; } = false;
|
||||
[Timestamp]
|
||||
public byte[] Timestamp { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MareSynchronosServer.Models
|
||||
{
|
||||
public class ForbiddenUploadEntry
|
||||
{
|
||||
[Key]
|
||||
public string Hash { get; set; }
|
||||
public string ForbiddenBy { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,5 +11,7 @@ namespace MareSynchronosServer.Models
|
||||
public string CharacterIdentification { get; set; }
|
||||
[Timestamp]
|
||||
public byte[] Timestamp { get; set; }
|
||||
|
||||
public bool IsAdmin { get; set; } = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace MareSynchronosServer
|
||||
services.AddDatabaseDeveloperPageExceptionFilter();
|
||||
services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultScheme = SecretKeyAuthenticationHandler.AUTH_SCHEME;
|
||||
options.DefaultScheme = SecretKeyAuthenticationHandler.AuthScheme;
|
||||
})
|
||||
.AddScheme<AuthenticationSchemeOptions, SecretKeyAuthenticationHandler>(SecretKeyAuthenticationHandler.AUTH_SCHEME, options => { });
|
||||
.AddScheme<AuthenticationSchemeOptions, SecretKeyAuthenticationHandler>(SecretKeyAuthenticationHandler.AuthScheme, options => { });
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
@@ -88,17 +88,17 @@ namespace MareSynchronosServer
|
||||
{
|
||||
endpoints.MapHub<ConnectionHub>("/heartbeat", options =>
|
||||
{
|
||||
options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling;
|
||||
options.Transports = HttpTransportType.WebSockets;
|
||||
});
|
||||
endpoints.MapHub<UserHub>("/user", options =>
|
||||
{
|
||||
options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling;
|
||||
options.Transports = HttpTransportType.WebSockets;
|
||||
});
|
||||
endpoints.MapHub<FilesHub>("/files", options =>
|
||||
{
|
||||
options.ApplicationMaxBufferSize = long.MaxValue;
|
||||
options.TransportMaxBufferSize = long.MaxValue;
|
||||
options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling;
|
||||
options.Transports = HttpTransportType.WebSockets;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user