From bd8f1823bb4dc7f8ab7d9c3a57eed5a3cf962b0c Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 23 May 2022 13:59:15 -0700 Subject: [PATCH] Sliding expiration for auth cookie and a little clean up (cherry picked from commit 05ee4e644907b7f1e84589465ac9ab1848f5a766) --- .../Authentication/AuthenticationBuilderExtensions.cs | 1 + src/Readarr.Http/Authentication/AuthenticationService.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Readarr.Http/Authentication/AuthenticationBuilderExtensions.cs b/src/Readarr.Http/Authentication/AuthenticationBuilderExtensions.cs index caf128abf..e0d78555d 100644 --- a/src/Readarr.Http/Authentication/AuthenticationBuilderExtensions.cs +++ b/src/Readarr.Http/Authentication/AuthenticationBuilderExtensions.cs @@ -33,6 +33,7 @@ namespace Readarr.Http.Authentication options.AccessDeniedPath = "/login?loginFailed=true"; options.LoginPath = "/login"; options.ExpireTimeSpan = TimeSpan.FromDays(7); + options.SlidingExpiration = true; }) .AddApiKey("API", options => { diff --git a/src/Readarr.Http/Authentication/AuthenticationService.cs b/src/Readarr.Http/Authentication/AuthenticationService.cs index ab3aa5b2d..dd99265b1 100644 --- a/src/Readarr.Http/Authentication/AuthenticationService.cs +++ b/src/Readarr.Http/Authentication/AuthenticationService.cs @@ -1,5 +1,8 @@ +using System; +using System.Net; using Microsoft.AspNetCore.Http; using NLog; +using NzbDrone.Common.Extensions; using NzbDrone.Core.Authentication; using NzbDrone.Core.Configuration; using Readarr.Http.Extensions; @@ -15,17 +18,14 @@ namespace Readarr.Http.Authentication public class AuthenticationService : IAuthenticationService { - private const string AnonymousUser = "Anonymous"; private static readonly Logger _authLogger = LogManager.GetLogger("Auth"); private readonly IUserService _userService; - private static string API_KEY; private static AuthenticationType AUTH_METHOD; public AuthenticationService(IConfigFileProvider configFileProvider, IUserService userService) { _userService = userService; - API_KEY = configFileProvider.ApiKey; AUTH_METHOD = configFileProvider.AuthenticationMethod; }