2017-09-13 08:47:34 +02:00
|
|
|
|
using BTCPayServer.Configuration;
|
2019-10-03 05:41:53 +02:00
|
|
|
|
using BTCPayServer.Services.Altcoins.Monero;
|
2017-12-16 17:04:20 +01:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2017-09-13 08:47:34 +02:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using NBitpayClient;
|
|
|
|
|
using NBitcoin;
|
|
|
|
|
using BTCPayServer.Data;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using BTCPayServer.Services;
|
2017-10-20 21:06:37 +02:00
|
|
|
|
using BTCPayServer.Services.Invoices;
|
2017-09-15 09:06:57 +02:00
|
|
|
|
using BTCPayServer.Services.Rates;
|
|
|
|
|
using BTCPayServer.Services.Stores;
|
|
|
|
|
using BTCPayServer.Services.Fees;
|
2017-09-15 12:25:02 +02:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2017-09-22 18:31:29 +02:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using BTCPayServer.Controllers;
|
|
|
|
|
using BTCPayServer.Services.Mails;
|
2017-09-27 16:56:43 +02:00
|
|
|
|
using System.Threading;
|
2017-10-06 03:37:38 +02:00
|
|
|
|
using BTCPayServer.Services.Wallets;
|
2017-12-16 17:04:20 +01:00
|
|
|
|
using BTCPayServer.Logging;
|
2018-01-07 18:36:41 +01:00
|
|
|
|
using BTCPayServer.HostedServices;
|
2020-02-18 10:50:01 +01:00
|
|
|
|
using BTCPayServer.Hosting.OpenApi;
|
2019-01-14 22:43:29 +01:00
|
|
|
|
using BTCPayServer.PaymentRequest;
|
2019-05-24 08:11:38 +02:00
|
|
|
|
using BTCPayServer.Payments;
|
|
|
|
|
using BTCPayServer.Payments.Bitcoin;
|
2018-10-24 07:52:19 +02:00
|
|
|
|
using BTCPayServer.Payments.Changelly;
|
2019-01-07 09:52:27 +01:00
|
|
|
|
using BTCPayServer.Payments.Lightning;
|
2018-04-29 19:33:42 +02:00
|
|
|
|
using BTCPayServer.Security;
|
2020-02-24 14:36:15 +01:00
|
|
|
|
using BTCPayServer.Security.APIKeys;
|
2019-01-14 22:43:29 +01:00
|
|
|
|
using BTCPayServer.Services.PaymentRequests;
|
2018-07-26 15:32:24 +02:00
|
|
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
|
|
|
using NBXplorer.DerivationStrategy;
|
2018-08-25 13:28:46 +02:00
|
|
|
|
using NicolasDorier.RateLimits;
|
2018-10-28 13:19:18 +01:00
|
|
|
|
using Npgsql;
|
2019-02-19 05:04:58 +01:00
|
|
|
|
using BTCPayServer.Services.Apps;
|
2019-10-02 19:32:41 +02:00
|
|
|
|
using BTCPayServer.U2F;
|
2019-03-24 01:10:16 +01:00
|
|
|
|
using BundlerMinifier.TagHelpers;
|
2019-10-12 13:35:30 +02:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using BTCPayServer.Security.Bitpay;
|
2019-11-16 06:06:37 +01:00
|
|
|
|
using Serilog;
|
2019-07-01 05:39:25 +02:00
|
|
|
|
|
2017-09-13 08:47:34 +02:00
|
|
|
|
namespace BTCPayServer.Hosting
|
|
|
|
|
{
|
2017-10-27 10:53:04 +02:00
|
|
|
|
public static class BTCPayServerServices
|
|
|
|
|
{
|
2019-05-14 17:46:43 +02:00
|
|
|
|
public static IServiceCollection AddBTCPayServer(this IServiceCollection services, IConfiguration configuration)
|
2017-10-27 10:53:04 +02:00
|
|
|
|
{
|
2019-10-03 10:06:49 +02:00
|
|
|
|
services.AddSingleton<MvcNewtonsoftJsonOptions>(o => o.GetRequiredService<IOptions<MvcNewtonsoftJsonOptions>>().Value);
|
2017-10-27 10:53:04 +02:00
|
|
|
|
services.AddDbContext<ApplicationDbContext>((provider, o) =>
|
|
|
|
|
{
|
|
|
|
|
var factory = provider.GetRequiredService<ApplicationDbContextFactory>();
|
|
|
|
|
factory.ConfigureBuilder(o);
|
|
|
|
|
});
|
2018-08-21 07:33:13 +02:00
|
|
|
|
services.AddHttpClient();
|
2019-06-18 06:37:24 +02:00
|
|
|
|
services.AddHttpClient(nameof(ExplorerClientProvider), httpClient =>
|
|
|
|
|
{
|
|
|
|
|
httpClient.Timeout = Timeout.InfiniteTimeSpan;
|
|
|
|
|
});
|
2019-10-01 08:30:27 +02:00
|
|
|
|
services.AddMoneroLike();
|
2017-10-27 10:53:04 +02:00
|
|
|
|
services.TryAddSingleton<SettingsRepository>();
|
2019-03-17 04:57:18 +01:00
|
|
|
|
services.TryAddSingleton<TorServices>();
|
2019-03-17 16:03:02 +01:00
|
|
|
|
services.TryAddSingleton<SocketFactory>();
|
2019-04-10 18:10:29 +02:00
|
|
|
|
services.TryAddSingleton<LightningClientFactoryService>();
|
2017-10-27 10:53:04 +02:00
|
|
|
|
services.TryAddSingleton<InvoicePaymentNotification>();
|
2019-05-14 17:46:43 +02:00
|
|
|
|
services.TryAddSingleton<BTCPayServerOptions>(o =>
|
|
|
|
|
o.GetRequiredService<IOptions<BTCPayServerOptions>>().Value);
|
2019-07-08 05:12:39 +02:00
|
|
|
|
services.AddStartupTask<MigrationStartupTask>();
|
2017-12-16 17:04:20 +01:00
|
|
|
|
services.TryAddSingleton<InvoiceRepository>(o =>
|
|
|
|
|
{
|
|
|
|
|
var opts = o.GetRequiredService<BTCPayServerOptions>();
|
|
|
|
|
var dbContext = o.GetRequiredService<ApplicationDbContextFactory>();
|
|
|
|
|
var dbpath = Path.Combine(opts.DataDir, "InvoiceDB");
|
|
|
|
|
if (!Directory.Exists(dbpath))
|
|
|
|
|
Directory.CreateDirectory(dbpath);
|
2019-06-04 03:17:26 +02:00
|
|
|
|
return new InvoiceRepository(dbContext, dbpath, o.GetRequiredService<BTCPayNetworkProvider>());
|
2017-10-27 10:53:04 +02:00
|
|
|
|
});
|
|
|
|
|
services.AddSingleton<BTCPayServerEnvironment>();
|
|
|
|
|
services.TryAddSingleton<TokenRepository>();
|
2019-08-02 17:42:30 +02:00
|
|
|
|
services.TryAddSingleton<WalletRepository>();
|
2017-12-17 06:17:42 +01:00
|
|
|
|
services.TryAddSingleton<EventAggregator>();
|
2019-01-14 22:43:29 +01:00
|
|
|
|
services.TryAddSingleton<PaymentRequestService>();
|
2019-05-02 14:01:08 +02:00
|
|
|
|
services.TryAddSingleton<U2FService>();
|
2017-12-16 17:04:20 +01:00
|
|
|
|
services.TryAddSingleton<ApplicationDbContextFactory>(o =>
|
|
|
|
|
{
|
|
|
|
|
var opts = o.GetRequiredService<BTCPayServerOptions>();
|
|
|
|
|
ApplicationDbContextFactory dbContext = null;
|
2018-10-27 16:15:21 +02:00
|
|
|
|
if (!String.IsNullOrEmpty(opts.PostgresConnectionString))
|
2017-12-16 17:04:20 +01:00
|
|
|
|
{
|
2018-10-27 16:15:21 +02:00
|
|
|
|
Logs.Configuration.LogInformation($"Postgres DB used ({opts.PostgresConnectionString})");
|
|
|
|
|
dbContext = new ApplicationDbContextFactory(DatabaseType.Postgres, opts.PostgresConnectionString);
|
|
|
|
|
}
|
|
|
|
|
else if(!String.IsNullOrEmpty(opts.MySQLConnectionString))
|
|
|
|
|
{
|
|
|
|
|
Logs.Configuration.LogInformation($"MySQL DB used ({opts.MySQLConnectionString})");
|
2019-09-06 08:13:26 +02:00
|
|
|
|
Logs.Configuration.LogWarning("MySQL is not widely tested and should be considered experimental, we advise you to use postgres instead.");
|
2018-10-27 16:15:21 +02:00
|
|
|
|
dbContext = new ApplicationDbContextFactory(DatabaseType.MySQL, opts.MySQLConnectionString);
|
2017-12-16 17:04:20 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-10-27 16:15:21 +02:00
|
|
|
|
var connStr = "Data Source=" + Path.Combine(opts.DataDir, "sqllite.db");
|
|
|
|
|
Logs.Configuration.LogInformation($"SQLite DB used ({connStr})");
|
2019-09-06 08:13:26 +02:00
|
|
|
|
Logs.Configuration.LogWarning("MySQL is not widely tested and should be considered experimental, we advise you to use postgres instead.");
|
2018-10-27 16:15:21 +02:00
|
|
|
|
dbContext = new ApplicationDbContextFactory(DatabaseType.Sqlite, connStr);
|
2017-12-16 17:04:20 +01:00
|
|
|
|
}
|
2018-10-27 16:15:21 +02:00
|
|
|
|
|
2017-12-16 17:04:20 +01:00
|
|
|
|
return dbContext;
|
|
|
|
|
});
|
2017-12-21 07:52:04 +01:00
|
|
|
|
|
|
|
|
|
services.TryAddSingleton<BTCPayNetworkProvider>(o =>
|
|
|
|
|
{
|
|
|
|
|
var opts = o.GetRequiredService<BTCPayServerOptions>();
|
2018-02-25 16:48:12 +01:00
|
|
|
|
return opts.NetworkProvider;
|
2017-12-21 07:52:04 +01:00
|
|
|
|
});
|
|
|
|
|
|
2019-02-19 05:04:58 +01:00
|
|
|
|
services.TryAddSingleton<AppService>();
|
2019-08-10 07:05:11 +02:00
|
|
|
|
services.TryAddTransient<Safe>();
|
2019-02-17 08:53:41 +01:00
|
|
|
|
services.TryAddSingleton<Ganss.XSS.HtmlSanitizer>(o =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var htmlSanitizer = new Ganss.XSS.HtmlSanitizer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
htmlSanitizer.RemovingAtRule += (sender, args) =>
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
htmlSanitizer.RemovingTag += (sender, args) =>
|
|
|
|
|
{
|
|
|
|
|
if (args.Tag.TagName.Equals("img", StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (!args.Tag.ClassList.Contains("img-fluid"))
|
|
|
|
|
{
|
|
|
|
|
args.Tag.ClassList.Add("img-fluid");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
args.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
htmlSanitizer.RemovingAttribute += (sender, args) =>
|
|
|
|
|
{
|
|
|
|
|
if (args.Tag.TagName.Equals("img", StringComparison.InvariantCultureIgnoreCase) &&
|
|
|
|
|
args.Attribute.Name.Equals("src", StringComparison.InvariantCultureIgnoreCase) &&
|
|
|
|
|
args.Reason == Ganss.XSS.RemoveReason.NotAllowedUrlValue)
|
|
|
|
|
{
|
|
|
|
|
args.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
htmlSanitizer.RemovingStyle += (sender, args) => { args.Cancel = true; };
|
|
|
|
|
htmlSanitizer.AllowedAttributes.Add("class");
|
|
|
|
|
htmlSanitizer.AllowedTags.Add("iframe");
|
|
|
|
|
htmlSanitizer.AllowedTags.Remove("img");
|
|
|
|
|
htmlSanitizer.AllowedAttributes.Add("webkitallowfullscreen");
|
|
|
|
|
htmlSanitizer.AllowedAttributes.Add("allowfullscreen");
|
|
|
|
|
return htmlSanitizer;
|
|
|
|
|
});
|
2018-08-30 20:16:24 +02:00
|
|
|
|
|
2018-07-22 11:38:14 +02:00
|
|
|
|
services.TryAddSingleton<LightningConfigurationProvider>();
|
2018-03-23 09:27:48 +01:00
|
|
|
|
services.TryAddSingleton<LanguageService>();
|
2018-01-07 20:14:35 +01:00
|
|
|
|
services.TryAddSingleton<NBXplorerDashboard>();
|
2017-10-27 10:53:04 +02:00
|
|
|
|
services.TryAddSingleton<StoreRepository>();
|
2019-01-14 22:43:29 +01:00
|
|
|
|
services.TryAddSingleton<PaymentRequestRepository>();
|
2018-01-11 06:36:12 +01:00
|
|
|
|
services.TryAddSingleton<BTCPayWalletProvider>();
|
2020-01-18 06:12:27 +01:00
|
|
|
|
services.TryAddSingleton<WalletReceiveStateService>();
|
2017-10-27 10:53:04 +02:00
|
|
|
|
services.TryAddSingleton<CurrencyNameTable>();
|
2018-01-07 18:36:41 +01:00
|
|
|
|
services.TryAddSingleton<IFeeProviderFactory>(o => new NBXplorerFeeProviderFactory(o.GetRequiredService<ExplorerClientProvider>())
|
2017-10-27 10:53:04 +02:00
|
|
|
|
{
|
2019-11-07 01:21:33 +01:00
|
|
|
|
Fallback = new FeeRate(100L, 1)
|
2017-10-27 10:53:04 +02:00
|
|
|
|
});
|
2017-12-16 17:04:20 +01:00
|
|
|
|
|
2018-04-24 00:42:03 +02:00
|
|
|
|
services.AddSingleton<CssThemeManager>();
|
2018-07-26 15:32:24 +02:00
|
|
|
|
services.Configure<MvcOptions>((o) => {
|
|
|
|
|
o.Filters.Add(new ContentSecurityPolicyCssThemeManager());
|
|
|
|
|
o.ModelMetadataDetailsProviders.Add(new SuppressChildValidationMetadataProvider(typeof(WalletId)));
|
|
|
|
|
o.ModelMetadataDetailsProviders.Add(new SuppressChildValidationMetadataProvider(typeof(DerivationStrategyBase)));
|
|
|
|
|
});
|
2018-04-24 00:42:03 +02:00
|
|
|
|
services.AddSingleton<IHostedService, CssThemeManagerHostedService>();
|
|
|
|
|
|
2019-08-27 16:30:25 +02:00
|
|
|
|
services.AddSingleton<HostedServices.CheckConfigurationHostedService>();
|
|
|
|
|
services.AddSingleton<IHostedService, HostedServices.CheckConfigurationHostedService>(o => o.GetRequiredService<CheckConfigurationHostedService>());
|
2019-05-24 08:11:38 +02:00
|
|
|
|
|
|
|
|
|
services.AddSingleton<BitcoinLikePaymentHandler>();
|
|
|
|
|
services.AddSingleton<IPaymentMethodHandler>(provider => provider.GetService<BitcoinLikePaymentHandler>());
|
|
|
|
|
services.AddSingleton<IHostedService, NBXplorerListener>();
|
2018-08-12 14:38:45 +02:00
|
|
|
|
|
2019-01-07 09:52:27 +01:00
|
|
|
|
services.AddSingleton<LightningLikePaymentHandler>();
|
2019-05-24 08:11:38 +02:00
|
|
|
|
services.AddSingleton<IPaymentMethodHandler>(provider => provider.GetService<LightningLikePaymentHandler>());
|
|
|
|
|
services.AddSingleton<IHostedService, LightningListener>();
|
|
|
|
|
|
2019-05-29 16:33:31 +02:00
|
|
|
|
services.AddSingleton<PaymentMethodHandlerDictionary>();
|
|
|
|
|
|
2018-10-24 07:52:19 +02:00
|
|
|
|
services.AddSingleton<ChangellyClientProvider>();
|
2018-02-20 04:45:04 +01:00
|
|
|
|
|
2018-01-07 18:36:41 +01:00
|
|
|
|
services.AddSingleton<IHostedService, NBXplorerWaiters>();
|
|
|
|
|
services.AddSingleton<IHostedService, InvoiceNotificationManager>();
|
|
|
|
|
services.AddSingleton<IHostedService, InvoiceWatcher>();
|
2018-04-14 15:35:52 +02:00
|
|
|
|
services.AddSingleton<IHostedService, RatesHostedService>();
|
2019-01-16 11:14:45 +01:00
|
|
|
|
services.AddSingleton<IHostedService, BackgroundJobSchedulerHostedService>();
|
2019-02-19 05:18:30 +01:00
|
|
|
|
services.AddSingleton<IHostedService, AppHubStreamer>();
|
2019-09-02 15:37:52 +02:00
|
|
|
|
services.AddSingleton<IHostedService, AppInventoryUpdaterHostedService>();
|
2019-07-24 10:59:30 +02:00
|
|
|
|
services.AddSingleton<IHostedService, DynamicDnsHostedService>();
|
2019-03-17 13:07:24 +01:00
|
|
|
|
services.AddSingleton<IHostedService, TorServicesHostedService>();
|
2019-01-14 22:43:29 +01:00
|
|
|
|
services.AddSingleton<IHostedService, PaymentRequestStreamer>();
|
2020-01-18 06:12:27 +01:00
|
|
|
|
services.AddSingleton<IHostedService, WalletReceiveCacheUpdater>();
|
2019-01-16 11:14:45 +01:00
|
|
|
|
services.AddSingleton<IBackgroundJobClient, BackgroundJobClient>();
|
2019-10-12 13:35:30 +02:00
|
|
|
|
services.AddScoped<IAuthorizationHandler, CookieAuthorizationHandler>();
|
|
|
|
|
services.AddScoped<IAuthorizationHandler, BitpayAuthorizationHandler>();
|
2018-01-07 18:36:41 +01:00
|
|
|
|
|
|
|
|
|
services.TryAddSingleton<ExplorerClientProvider>();
|
2017-10-27 10:53:04 +02:00
|
|
|
|
services.TryAddSingleton<Bitpay>(o =>
|
|
|
|
|
{
|
2018-04-19 09:54:25 +02:00
|
|
|
|
if (o.GetRequiredService<BTCPayServerOptions>().NetworkType == NetworkType.Mainnet)
|
2017-10-27 10:53:04 +02:00
|
|
|
|
return new Bitpay(new Key(), new Uri("https://bitpay.com/"));
|
|
|
|
|
else
|
|
|
|
|
return new Bitpay(new Key(), new Uri("https://test.bitpay.com/"));
|
|
|
|
|
});
|
2018-08-22 09:53:40 +02:00
|
|
|
|
services.TryAddSingleton<RateProviderFactory>();
|
|
|
|
|
services.TryAddSingleton<RateFetcher>();
|
2017-12-16 17:04:20 +01:00
|
|
|
|
|
2017-10-27 10:53:04 +02:00
|
|
|
|
services.TryAddScoped<IHttpContextAccessor, HttpContextAccessor>();
|
|
|
|
|
services.AddTransient<AccessTokenController>();
|
|
|
|
|
services.AddTransient<InvoiceController>();
|
2018-12-28 12:07:15 +01:00
|
|
|
|
services.AddTransient<AppsPublicController>();
|
2019-01-14 22:43:29 +01:00
|
|
|
|
services.AddTransient<PaymentRequestController>();
|
2017-10-27 10:53:04 +02:00
|
|
|
|
// Add application services.
|
2019-01-06 15:53:37 +01:00
|
|
|
|
services.AddSingleton<EmailSenderFactory>();
|
2020-02-24 14:36:15 +01:00
|
|
|
|
|
|
|
|
|
services.AddAPIKeyAuthentication();
|
|
|
|
|
services.AddBtcPayServerAuthenticationSchemes();
|
2019-10-12 13:35:30 +02:00
|
|
|
|
services.AddAuthorization(o => o.AddBTCPayPolicies());
|
2020-02-24 14:36:15 +01:00
|
|
|
|
// bundling
|
2019-03-23 15:24:29 +01:00
|
|
|
|
services.AddSingleton<IBundleProvider, ResourceBundleProvider>();
|
2018-02-21 07:48:25 +01:00
|
|
|
|
services.AddTransient<BundleOptions>(provider =>
|
2018-02-21 07:05:08 +01:00
|
|
|
|
{
|
2018-02-21 07:48:25 +01:00
|
|
|
|
var opts = provider.GetRequiredService<BTCPayServerOptions>();
|
|
|
|
|
var bundle = new BundleOptions();
|
2018-08-25 16:08:46 +02:00
|
|
|
|
bundle.UseBundles = opts.BundleJsCss;
|
2018-02-21 07:48:25 +01:00
|
|
|
|
bundle.AppendVersion = true;
|
|
|
|
|
return bundle;
|
2018-02-21 07:05:08 +01:00
|
|
|
|
});
|
2017-09-15 12:25:02 +02:00
|
|
|
|
|
2019-05-14 17:46:43 +02:00
|
|
|
|
services.AddCors(options =>
|
2018-08-06 05:04:36 +02:00
|
|
|
|
{
|
2019-05-14 17:46:43 +02:00
|
|
|
|
options.AddPolicy(CorsPolicies.All, p => p.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
|
2018-08-06 05:04:36 +02:00
|
|
|
|
});
|
2020-02-19 09:35:23 +01:00
|
|
|
|
services.AddSingleton(provider =>
|
|
|
|
|
{
|
|
|
|
|
var btcPayEnv = provider.GetService<BTCPayServerEnvironment>();
|
|
|
|
|
var rateLimits = new RateLimitService();
|
|
|
|
|
if (btcPayEnv.IsDevelopping)
|
|
|
|
|
{
|
|
|
|
|
rateLimits.SetZone($"zone={ZoneLimits.Login} rate=1000r/min burst=100 nodelay");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rateLimits.SetZone($"zone={ZoneLimits.Login} rate=5r/min burst=3 nodelay");
|
|
|
|
|
}
|
|
|
|
|
return rateLimits;
|
|
|
|
|
});
|
2020-02-18 10:50:01 +01:00
|
|
|
|
services.AddBTCPayOpenApi();
|
2019-11-16 06:06:37 +01:00
|
|
|
|
|
|
|
|
|
services.AddLogging(logBuilder =>
|
|
|
|
|
{
|
|
|
|
|
var debugLogFile = BTCPayServerOptions.GetDebugLog(configuration);
|
|
|
|
|
if (!string.IsNullOrEmpty(debugLogFile))
|
|
|
|
|
{
|
|
|
|
|
Serilog.Log.Logger = new LoggerConfiguration()
|
|
|
|
|
.Enrich.FromLogContext()
|
|
|
|
|
.MinimumLevel.Is(BTCPayServerOptions.GetDebugLogLevel(configuration))
|
|
|
|
|
.WriteTo.File(debugLogFile, rollingInterval: RollingInterval.Day, fileSizeLimitBytes: MAX_DEBUG_LOG_FILE_SIZE, rollOnFileSizeLimit: true, retainedFileCountLimit: 1)
|
|
|
|
|
.CreateLogger();
|
2020-01-16 06:00:31 +01:00
|
|
|
|
logBuilder.AddProvider(new Serilog.Extensions.Logging.SerilogLoggerProvider(Log.Logger));
|
2019-11-16 06:06:37 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
2017-10-27 10:53:04 +02:00
|
|
|
|
return services;
|
|
|
|
|
}
|
2019-11-16 06:06:37 +01:00
|
|
|
|
private const long MAX_DEBUG_LOG_FILE_SIZE = 2000000; // If debug log is in use roll it every N MB.
|
2020-02-24 14:36:15 +01:00
|
|
|
|
private static void AddBtcPayServerAuthenticationSchemes(this IServiceCollection services)
|
2019-05-14 17:46:43 +02:00
|
|
|
|
{
|
|
|
|
|
services.AddAuthentication()
|
|
|
|
|
.AddCookie()
|
2020-02-24 14:36:15 +01:00
|
|
|
|
.AddBitpayAuthentication()
|
|
|
|
|
.AddAPIKeyAuthentication();
|
2019-05-14 17:46:43 +02:00
|
|
|
|
}
|
2017-09-13 08:47:34 +02:00
|
|
|
|
|
2017-10-27 10:53:04 +02:00
|
|
|
|
public static IApplicationBuilder UsePayServer(this IApplicationBuilder app)
|
|
|
|
|
{
|
|
|
|
|
app.UseMiddleware<BTCPayMiddleware>();
|
2018-02-23 07:21:42 +01:00
|
|
|
|
return app;
|
2017-10-27 10:53:04 +02:00
|
|
|
|
}
|
2019-10-09 15:26:54 +02:00
|
|
|
|
public static IApplicationBuilder UseHeadersOverride(this IApplicationBuilder app)
|
|
|
|
|
{
|
|
|
|
|
app.UseMiddleware<HeadersOverrideMiddleware>();
|
|
|
|
|
return app;
|
|
|
|
|
}
|
2017-10-27 10:53:04 +02:00
|
|
|
|
}
|
2017-09-13 08:47:34 +02:00
|
|
|
|
}
|