mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-24 02:02:29 -04:00
Fix review comments
This commit is contained in:
parent
27e3cf1558
commit
2af5922af0
@ -231,7 +231,10 @@ namespace Emby.Server.Implementations
|
||||
}
|
||||
}
|
||||
|
||||
public IServiceProvider ServiceProvider;
|
||||
/// <summary>
|
||||
/// Gets or sets the service provider.
|
||||
/// </summary>
|
||||
public IServiceProvider ServiceProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the server configuration manager.
|
||||
@ -835,7 +838,7 @@ namespace Emby.Server.Implementations
|
||||
serviceCollection.AddSingleton<IAuthorizationContext>(authContext);
|
||||
serviceCollection.AddSingleton<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
|
||||
|
||||
AuthService = new AuthService(LoggerFactory, authContext, ServerConfigurationManager, SessionManager, NetworkManager);
|
||||
AuthService = new AuthService(LoggerFactory.CreateLogger<AuthService>(), authContext, ServerConfigurationManager, SessionManager, NetworkManager);
|
||||
serviceCollection.AddSingleton(AuthService);
|
||||
|
||||
SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory, ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory);
|
||||
|
@ -22,13 +22,13 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||
private readonly INetworkManager _networkManager;
|
||||
|
||||
public AuthService(
|
||||
ILoggerFactory loggerFactory,
|
||||
ILogger<AuthService> logger,
|
||||
IAuthorizationContext authorizationContext,
|
||||
IServerConfigurationManager config,
|
||||
ISessionManager sessionManager,
|
||||
INetworkManager networkManager)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger<AuthService>();
|
||||
_logger = logger;
|
||||
_authorizationContext = authorizationContext;
|
||||
_config = config;
|
||||
_sessionManager = sessionManager;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Api.Enums;
|
||||
using Jellyfin.Api.Constants;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -51,7 +51,7 @@ namespace Jellyfin.Api.Auth
|
||||
new Claim(ClaimTypes.Name, user.Name),
|
||||
new Claim(
|
||||
ClaimTypes.Role,
|
||||
value: user.Policy.IsAdministrator ? UserRole.Administrator.ToString() : UserRole.User.ToString())
|
||||
value: user.Policy.IsAdministrator ? UserRole.Administrator : UserRole.User)
|
||||
};
|
||||
var identity = new ClaimsIdentity(claims, Scheme.Name);
|
||||
var principal = new ClaimsPrincipal(identity);
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Api.Enums;
|
||||
using Jellyfin.Api.Constants;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
@ -28,7 +28,7 @@ namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy
|
||||
{
|
||||
context.Succeed(firstTimeSetupOrElevatedRequirement);
|
||||
}
|
||||
else if (context.User.IsInRole(UserRole.Administrator.ToString()))
|
||||
else if (context.User.IsInRole(UserRole.Administrator))
|
||||
{
|
||||
context.Succeed(firstTimeSetupOrElevatedRequirement);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Api.Enums;
|
||||
using Jellyfin.Api.Constants;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Jellyfin.Api.Auth.RequiresElevationPolicy
|
||||
@ -12,7 +12,7 @@ namespace Jellyfin.Api.Auth.RequiresElevationPolicy
|
||||
/// <inheritdoc />
|
||||
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement)
|
||||
{
|
||||
if (context.User.IsInRole(UserRole.Administrator.ToString()))
|
||||
if (context.User.IsInRole(UserRole.Administrator))
|
||||
{
|
||||
context.Succeed(requirement);
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
namespace Jellyfin.Api.Enums
|
||||
namespace Jellyfin.Api.Constants
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum for user roles used in the authentication and authorization for the API.
|
||||
/// Constants for user roles used in the authentication and authorization for the API.
|
||||
/// </summary>
|
||||
public enum UserRole
|
||||
public static class UserRole
|
||||
{
|
||||
/// <summary>
|
||||
/// Guest user.
|
||||
/// </summary>
|
||||
Guest = 0,
|
||||
public const string Guest = "Guest";
|
||||
|
||||
/// <summary>
|
||||
/// Regular user with no special privileges.
|
||||
/// </summary>
|
||||
User = 1,
|
||||
public const string User = "User";
|
||||
|
||||
/// <summary>
|
||||
/// Administrator user with elevated privileges.
|
||||
/// </summary>
|
||||
Administrator = 2
|
||||
public const string Administrator = "Administrator";
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
|
||||
<!-- Code analysers-->
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.7" PrivateAssets="All" />
|
||||
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
|
||||
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user