Persist auth keys across deployments
This commit is contained in:
@@ -95,7 +95,8 @@ public class LoginModel(AuthService authService) : PageModel
|
||||
|
||||
var properties = new AuthenticationProperties
|
||||
{
|
||||
IsPersistent = false,
|
||||
IsPersistent = true,
|
||||
ExpiresUtc = DateTimeOffset.UtcNow.AddHours(12),
|
||||
RedirectUri = RedirectUrl
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Unicode;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
@@ -54,6 +55,14 @@ builder.Host.UseSerilog((context, config) =>
|
||||
builder.Services.AddAuthorization();
|
||||
builder.Services.AddProblemDetails();
|
||||
builder.Services.AddHealthChecks();
|
||||
var dataProtectionKeyPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
||||
".taxbaik",
|
||||
"data-protection-keys");
|
||||
Directory.CreateDirectory(dataProtectionKeyPath);
|
||||
builder.Services.AddDataProtection()
|
||||
.SetApplicationName("TaxBaik.Web")
|
||||
.PersistKeysToFileSystem(new DirectoryInfo(dataProtectionKeyPath));
|
||||
builder.Services.AddRateLimiter(options =>
|
||||
{
|
||||
options.RejectionStatusCode = StatusCodes.Status429TooManyRequests;
|
||||
|
||||
Reference in New Issue
Block a user