jellyfin-server/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs

19 lines
560 B
C#
Raw Normal View History

using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
namespace Jellyfin.Api.Auth.RequiresElevationPolicy
{
public class RequiresElevationHandler : AuthorizationHandler<RequiresElevationRequirement>
{
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement)
{
if (context.User.IsInRole("Administrator"))
{
context.Succeed(requirement);
}
return Task.CompletedTask;
}
}
}