mirror of
https://github.com/Readarr/Readarr
synced 2025-12-15 12:52:27 +01:00
Fixed: Forms login persists across restarts in docker
Closes #1307 (cherry picked from commit a219b4a1b869863b2ef47d4bdf33d308cb261ba3)
This commit is contained in:
parent
1835f15460
commit
a3a914adfe
3 changed files with 15 additions and 1 deletions
|
|
@ -259,6 +259,11 @@ public static string GetAppDataPath(this IAppFolderInfo appFolderInfo)
|
|||
return appFolderInfo.AppDataFolder;
|
||||
}
|
||||
|
||||
public static string GetDataProtectionPath(this IAppFolderInfo appFolderInfo)
|
||||
{
|
||||
return Path.Combine(GetAppDataPath(appFolderInfo), "asp");
|
||||
}
|
||||
|
||||
public static string GetLogFolder(this IAppFolderInfo appFolderInfo)
|
||||
{
|
||||
return Path.Combine(GetAppDataPath(appFolderInfo), "logs");
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@
|
|||
using System.Text;
|
||||
using DryIoc;
|
||||
using DryIoc.Microsoft.DependencyInjection;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Hosting.WindowsServices;
|
||||
using NLog;
|
||||
|
|
@ -135,6 +137,7 @@ public static IHostBuilder CreateConsoleHostBuilder(string[] args, StartupContex
|
|||
})
|
||||
.ConfigureWebHost(builder =>
|
||||
{
|
||||
builder.UseConfiguration(config);
|
||||
builder.UseUrls(urls.ToArray());
|
||||
builder.UseKestrel(options =>
|
||||
{
|
||||
|
|
@ -190,6 +193,7 @@ private static IConfiguration GetConfiguration(StartupContext context)
|
|||
var appFolder = new AppFolderInfo(context);
|
||||
return new ConfigurationBuilder()
|
||||
.AddXmlFile(appFolder.GetConfigPath(), optional: true, reloadOnChange: false)
|
||||
.AddInMemoryCollection(new List<KeyValuePair<string, string>> { new ("dataProtectionFolder", appFolder.GetDataProtectionPath()) })
|
||||
.Build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DryIoc;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
@ -46,6 +47,7 @@ public void ConfigureServices(IServiceCollection services)
|
|||
b.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
||||
b.AddFilter("Microsoft.AspNetCore", Microsoft.Extensions.Logging.LogLevel.Warning);
|
||||
b.AddFilter("Readarr.Http.Authentication", LogLevel.Information);
|
||||
b.AddFilter("Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager", LogLevel.Error);
|
||||
b.AddNLog();
|
||||
});
|
||||
|
||||
|
|
@ -95,6 +97,9 @@ public void ConfigureServices(IServiceCollection services)
|
|||
options.PayloadSerializerOptions = STJson.GetSerializerSettings();
|
||||
});
|
||||
|
||||
services.AddDataProtection()
|
||||
.PersistKeysToFileSystem(new DirectoryInfo(Configuration["dataProtectionFolder"]));
|
||||
|
||||
services.AddSingleton<IAuthorizationPolicyProvider, UiAuthorizationPolicyProvider>();
|
||||
services.AddAuthorization(options =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue