mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-28 10:24:22 +01:00
* Remove OpenIddict * Add API Key system * Revert removing OpenIddict * fix rebase * fix tests * pr changes * fix tests * fix apikey test * pr change * fix db * add migration attrs * fix migration error * PR Changes * Fix sqlite migration * change api key to use Authorization Header * add supportAddForeignKey * use tempdata status message * fix add api key css * remove redirect url + app identifier feature :(
49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
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)
|
|
{
|
|
options.AddPolicy(CanModifyStoreSettings.Key);
|
|
options.AddPolicy(CanListStoreSettings.Key);
|
|
options.AddPolicy(CanCreateInvoice.Key);
|
|
options.AddPolicy(CanGetRates.Key);
|
|
options.AddPolicy(CanModifyServerSettings.Key);
|
|
return options;
|
|
}
|
|
|
|
public static void AddPolicy(this AuthorizationOptions options, string policy)
|
|
{
|
|
options.AddPolicy(policy, o => o.AddRequirements(new PolicyRequirement(policy)));
|
|
}
|
|
|
|
public class CanModifyServerSettings
|
|
{
|
|
public const string Key = "btcpay.store.canmodifyserversettings";
|
|
}
|
|
public class CanModifyStoreSettings
|
|
{
|
|
public const string Key = "btcpay.store.canmodifystoresettings";
|
|
}
|
|
public class CanListStoreSettings
|
|
{
|
|
public const string Key = "btcpay.store.canliststoresettings";
|
|
}
|
|
public class CanCreateInvoice
|
|
{
|
|
public const string Key = "btcpay.store.cancreateinvoice";
|
|
}
|
|
|
|
public class CanGetRates
|
|
{
|
|
public const string Key = "btcpay.store.cangetrates";
|
|
}
|
|
}
|
|
}
|