Fix more review comments

This commit is contained in:
Claus Vium
2019-11-24 19:25:46 +01:00
parent 2af5922af0
commit 47a4f2f387
10 changed files with 62 additions and 20 deletions

View File

@@ -2,6 +2,7 @@ using Jellyfin.Api;
using Jellyfin.Api.Auth;
using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy;
using Jellyfin.Api.Auth.RequiresElevationPolicy;
using Jellyfin.Api.Constants;
using Jellyfin.Api.Controllers;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
@@ -27,17 +28,17 @@ namespace Jellyfin.Server.Extensions
return serviceCollection.AddAuthorizationCore(options =>
{
options.AddPolicy(
"RequiresElevation",
Policies.RequiresElevation,
policy =>
{
policy.AddAuthenticationSchemes("CustomAuthentication");
policy.AddAuthenticationSchemes(AuthenticationSchemes.CustomAuthentication);
policy.AddRequirements(new RequiresElevationRequirement());
});
options.AddPolicy(
"FirstTimeSetupOrElevated",
Policies.FirstTimeSetupOrElevated,
policy =>
{
policy.AddAuthenticationSchemes("CustomAuthentication");
policy.AddAuthenticationSchemes(AuthenticationSchemes.CustomAuthentication);
policy.AddRequirements(new FirstTimeSetupOrElevatedRequirement());
});
});
@@ -50,8 +51,8 @@ namespace Jellyfin.Server.Extensions
/// <returns>The updated service collection.</returns>
public static AuthenticationBuilder AddCustomAuthentication(this IServiceCollection serviceCollection)
{
return serviceCollection.AddAuthentication("CustomAuthentication")
.AddScheme<AuthenticationSchemeOptions, CustomAuthenticationHandler>("CustomAuthentication", null);
return serviceCollection.AddAuthentication(AuthenticationSchemes.CustomAuthentication)
.AddScheme<AuthenticationSchemeOptions, CustomAuthenticationHandler>(AuthenticationSchemes.CustomAuthentication, null);
}
/// <summary>