From bee3e61f53921070a333ffd750a0357a22604447 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 10 Jun 2025 12:33:52 +0300 Subject: [PATCH] Fixed: Redirect loop for removed basic auth method --- .../AuthenticationBuilderExtensions.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Prowlarr.Http/Authentication/AuthenticationBuilderExtensions.cs b/src/Prowlarr.Http/Authentication/AuthenticationBuilderExtensions.cs index c79245991..1491fbffc 100644 --- a/src/Prowlarr.Http/Authentication/AuthenticationBuilderExtensions.cs +++ b/src/Prowlarr.Http/Authentication/AuthenticationBuilderExtensions.cs @@ -11,7 +11,7 @@ namespace Prowlarr.Http.Authentication { public static class AuthenticationBuilderExtensions { - private static readonly Regex CookieNameRegex = new Regex(@"[^a-z0-9]+", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex CookieNameRegex = new(@"[^a-z0-9]+", RegexOptions.Compiled | RegexOptions.IgnoreCase); public static AuthenticationBuilder AddApiKey(this AuthenticationBuilder authenticationBuilder, string name, Action options) { @@ -30,7 +30,7 @@ namespace Prowlarr.Http.Authentication public static AuthenticationBuilder AddAppAuthentication(this IServiceCollection services) { - services.AddOptions(AuthenticationType.Forms.ToString()) + services.AddOptions(nameof(AuthenticationType.Forms)) .Configure((options, configFileProvider) => { // Replace diacritics and replace non-word characters to ensure cookie name doesn't contain any valid URL characters not allowed in cookie names @@ -47,12 +47,9 @@ namespace Prowlarr.Http.Authentication }); return services.AddAuthentication() - .AddNone(AuthenticationType.None.ToString()) - .AddExternal(AuthenticationType.External.ToString()) -#pragma warning disable CS0618 // Type or member is obsolete - .AddCookie(AuthenticationType.Basic.ToString()) -#pragma warning restore CS0618 // Type or member is obsolete - .AddCookie(AuthenticationType.Forms.ToString()) + .AddNone(nameof(AuthenticationType.None)) + .AddExternal(nameof(AuthenticationType.External)) + .AddCookie(nameof(AuthenticationType.Forms)) .AddApiKey("API", options => { options.HeaderName = "X-Api-Key";