btcpayserver/BTCPayServer/Security/ServerPolicies.cs
2020-03-20 13:41:47 +09:00

28 lines
791 B
C#

using BTCPayServer.Client;
using Microsoft.AspNetCore.Authorization;
namespace BTCPayServer.Security
{
public static class ServerPolicies
{
public static AuthorizationOptions AddBTCPayPolicies(this AuthorizationOptions options)
{
foreach (var p in Policies.AllPolicies)
{
options.AddPolicy(p);
}
options.AddPolicy(CanGetRates.Key);
return options;
}
public static void AddPolicy(this AuthorizationOptions options, string policy)
{
options.AddPolicy(policy, o => o.AddRequirements(new PolicyRequirement(policy)));
}
public class CanGetRates
{
public const string Key = "btcpay.store.cangetrates";
}
}
}