using Microsoft.AspNetCore.Authorization;

namespace ZB.MOM.WW.MxGateway.Server.Dashboard;

/// <summary>
/// Requirement satisfied when the user has any one of the listed roles, or
/// when an environment-level bypass (auth disabled / loopback) is in effect.
/// </summary>
public sealed class DashboardAuthorizationRequirement(IReadOnlyList<string> requiredRoles) : IAuthorizationRequirement
{
    public IReadOnlyList<string> RequiredRoles { get; } = requiredRoles;

    public static DashboardAuthorizationRequirement AnyDashboardRole { get; } =
        new([DashboardRoles.Admin, DashboardRoles.Viewer]);

    public static DashboardAuthorizationRequirement AdminOnly { get; } =
        new([DashboardRoles.Admin]);
}
