Implemented the ability to change the JWT key on runtime. (#217)
* Implemented the ability to change the JWT key on runtime. * Added .7z file extension support * Cleanup * Added Feathub link * Code cleanup * Fixed up a build issue on CI
This commit is contained in:
parent
98e8b7297b
commit
03b49a5268
8 changed files with 67 additions and 24 deletions
|
@ -288,21 +288,6 @@ namespace API.Controllers
|
|||
return Ok(-1);
|
||||
}
|
||||
|
||||
private int GetNextChapterId(Volume currentVolume, int currentChapterId)
|
||||
{
|
||||
var next = false;
|
||||
foreach (var chapter in currentVolume.Chapters)
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
return chapter.Id;
|
||||
}
|
||||
if (currentChapterId == chapter.Id) next = true;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int GetNextChapterId(IEnumerable<Chapter> chapters, int currentChapterId)
|
||||
{
|
||||
var next = false;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace API.Parser
|
|||
{
|
||||
public static class Parser
|
||||
{
|
||||
public static readonly string ArchiveFileExtensions = @"\.cbz|\.zip|\.rar|\.cbr|\.tar.gz|\.7zip";
|
||||
public static readonly string ArchiveFileExtensions = @"\.cbz|\.zip|\.rar|\.cbr|\.tar.gz|\.7zip|\.7z";
|
||||
public static readonly string BookFileExtensions = @"\.epub";
|
||||
public static readonly string ImageFileExtensions = @"^(\.png|\.jpeg|\.jpg)";
|
||||
public static readonly Regex FontSrcUrlRegex = new Regex("(src:url\\(\"?'?)([a-z0-9/\\._]+)(\"?'?\\))", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
|
@ -14,7 +15,6 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Sentry;
|
||||
using Sentry.Extensions.Logging;
|
||||
|
||||
namespace API
|
||||
{
|
||||
|
@ -26,12 +26,26 @@ namespace API
|
|||
{
|
||||
}
|
||||
|
||||
private static string GetAppSettingFilename()
|
||||
{
|
||||
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
var isDevelopment = environment == Environments.Development;
|
||||
return "appSettings" + (isDevelopment ? ".Development" : "") + ".json";
|
||||
}
|
||||
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
// Before anything, check if JWT has been generated properly or if user still has default
|
||||
if (!Configuration.CheckIfJwtTokenSet(GetAppSettingFilename()))
|
||||
{
|
||||
Console.WriteLine("Generating JWT TokenKey for encrypting user sessions...");
|
||||
var rBytes = new byte[24];
|
||||
using (var crypto = new RNGCryptoServiceProvider()) crypto.GetBytes(rBytes);
|
||||
var base64 = Convert.ToBase64String(rBytes).Replace("/", "");
|
||||
Configuration.UpdateJwtToken(GetAppSettingFilename(), base64);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
|
||||
using var scope = host.Services.CreateScope();
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using API.Extensions;
|
||||
using API.Interfaces;
|
||||
using API.Middleware;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue