2018-04-30 02:33:42 +09:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
|
|
|
|
namespace BTCPayServer.Security
|
|
|
|
|
{
|
|
|
|
|
public static class Policies
|
|
|
|
|
{
|
|
|
|
|
public static AuthorizationOptions AddBTCPayPolicies(this AuthorizationOptions options)
|
|
|
|
|
{
|
2019-10-12 20:35:30 +09:00
|
|
|
|
options.AddPolicy(CanModifyStoreSettings.Key);
|
|
|
|
|
options.AddPolicy(CanCreateInvoice.Key);
|
|
|
|
|
options.AddPolicy(CanGetRates.Key);
|
|
|
|
|
options.AddPolicy(CanModifyServerSettings.Key);
|
2018-04-30 02:33:42 +09:00
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-12 20:35:30 +09:00
|
|
|
|
public static void AddPolicy(this AuthorizationOptions options, string policy)
|
2018-04-30 02:33:42 +09:00
|
|
|
|
{
|
2019-10-12 20:35:30 +09:00
|
|
|
|
options.AddPolicy(policy, o => o.AddRequirements(new PolicyRequirement(policy)));
|
2018-04-30 02:33:42 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class CanModifyServerSettings
|
|
|
|
|
{
|
|
|
|
|
public const string Key = "btcpay.store.canmodifyserversettings";
|
|
|
|
|
}
|
|
|
|
|
public class CanModifyStoreSettings
|
|
|
|
|
{
|
|
|
|
|
public const string Key = "btcpay.store.canmodifystoresettings";
|
|
|
|
|
}
|
2018-09-08 14:32:26 +09:00
|
|
|
|
public class CanCreateInvoice
|
|
|
|
|
{
|
|
|
|
|
public const string Key = "btcpay.store.cancreateinvoice";
|
|
|
|
|
}
|
2019-10-12 20:35:30 +09:00
|
|
|
|
|
|
|
|
|
public class CanGetRates
|
|
|
|
|
{
|
|
|
|
|
public const string Key = "btcpay.store.cangetrates";
|
|
|
|
|
}
|
2018-04-30 02:33:42 +09:00
|
|
|
|
}
|
|
|
|
|
}
|