Compare commits

..

3 Commits

Author SHA1 Message Date
bakerboy448
86b81948af Sync UiAuthorizationPolicyProvider with upstream
* Revert "Fixed: Fallback to Forms for removed Basic auth method"

This reverts commit fe198352a3.

* AuthPolicy Var fixes
2025-07-02 10:10:40 -05:00
Mark McDowall
54918e0c30 Change authentication to Forms if set to Basic
(cherry picked from commit 8e08b0cc3df904d39da5be38bc345cc701412a9d)
2025-06-28 09:29:52 -05:00
Bogdan
01dd793c0a Bump version to 2.0.1 2025-06-15 09:25:06 +03:00
3 changed files with 21 additions and 21 deletions

View File

@@ -9,7 +9,7 @@ variables:
testsFolder: './_tests'
yarnCacheFolder: $(Pipeline.Workspace)/.yarn
nugetCacheFolder: $(Pipeline.Workspace)/.nuget/packages
majorVersion: '2.0.0'
majorVersion: '2.0.1'
minorVersion: $[counter('minorVersion', 1)]
prowlarrVersion: '$(majorVersion).$(minorVersion)'
buildName: '$(Build.SourceBranchName).$(prowlarrVersion)'

View File

@@ -211,9 +211,20 @@ namespace NzbDrone.Core.Configuration
return AuthenticationType.Forms;
}
return Enum.TryParse<AuthenticationType>(_authOptions.Method, out var enumValue)
var value = Enum.TryParse<AuthenticationType>(_authOptions.Method, out var enumValue)
? enumValue
: GetValueEnum("AuthenticationMethod", AuthenticationType.None);
#pragma warning disable CS0618 // Type or member is obsolete
if (value == AuthenticationType.Basic)
#pragma warning restore CS0618 // Type or member is obsolete
{
SetValue("AuthenticationMethod", AuthenticationType.Forms);
return AuthenticationType.Forms;
}
return value;
}
}
@@ -389,6 +400,12 @@ namespace NzbDrone.Core.Configuration
{
SetValue("EnableSsl", false);
}
#pragma warning disable CS0618 // Type or member is obsolete
if (AuthenticationMethod == AuthenticationType.Basic)
#pragma warning restore CS0618 // Type or member is obsolete
{
SetValue("AuthenticationMethod", AuthenticationType.Forms);
}
}
private void DeleteOldValues()

View File

@@ -2,8 +2,6 @@ using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Options;
using NLog;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
namespace Prowlarr.Http.Authentication
@@ -12,17 +10,14 @@ namespace Prowlarr.Http.Authentication
{
private const string PolicyName = "UI";
private readonly IConfigFileProvider _config;
private readonly Logger _logger;
public DefaultAuthorizationPolicyProvider FallbackPolicyProvider { get; }
public UiAuthorizationPolicyProvider(IOptions<AuthorizationOptions> options,
IConfigFileProvider config,
Logger logger)
IConfigFileProvider config)
{
FallbackPolicyProvider = new DefaultAuthorizationPolicyProvider(options);
_config = config;
_logger = logger;
}
public Task<AuthorizationPolicy> GetDefaultPolicyAsync() => FallbackPolicyProvider.GetDefaultPolicyAsync();
@@ -33,19 +28,7 @@ namespace Prowlarr.Http.Authentication
{
if (policyName.Equals(PolicyName, StringComparison.OrdinalIgnoreCase))
{
var authenticationMethod = _config.AuthenticationMethod;
#pragma warning disable CS0618 // Type or member is obsolete
if (authenticationMethod == AuthenticationType.Basic)
#pragma warning restore CS0618 // Type or member is obsolete
{
_logger.Error("Basic authentication method was removed, use Forms authentication instead.");
authenticationMethod = AuthenticationType.Forms;
}
var policy = new AuthorizationPolicyBuilder()
.AddAuthenticationSchemes(authenticationMethod.ToString())
var policy = new AuthorizationPolicyBuilder(_config.AuthenticationMethod.ToString())
.AddRequirements(new BypassableDenyAnonymousAuthorizationRequirement());
return Task.FromResult(policy.Build());