mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
24 lines
727 B
C#
24 lines
727 B
C#
using System.Threading.Tasks;
|
|
using Jellyfin.Api.Constants;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace Jellyfin.Api.Auth.RequiresElevationPolicy
|
|
{
|
|
/// <summary>
|
|
/// Authorization handler for requiring elevated privileges.
|
|
/// </summary>
|
|
public class RequiresElevationHandler : AuthorizationHandler<RequiresElevationRequirement>
|
|
{
|
|
/// <inheritdoc />
|
|
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement)
|
|
{
|
|
if (context.User.IsInRole(UserRoles.Administrator))
|
|
{
|
|
context.Succeed(requirement);
|
|
}
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|