mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-01 05:04:28 +01:00
* Part 1 & Part 2 squashed commits pr changes pr fixes remove config for openid -- no need for it for now Part 1: OpenIddict - Minor Changes & Config prep Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies pr changes fix merge fix compile fix compile #2 Part 1: OpenIddict - Minor Changes & Config prep add missing nuget Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies * Part3: OpenIddict: Add Flows Event Handlers * pr changes * fix merge * fix rebase * fix imports * cleanup * do not allow u2f enabled accounts to log in * start better tests for flows * add tests * fixes * reintroduce dynamic policy as policies on jwt do not work without it * reduce logs * fix incorrect endpoint definitions * Add implicit flow e2e test * add code flow and refresh flow * do not allow jwt bearer auth for all requests( only those under /api) * remove commentedt code * make sure authorize attr is marked with scheme * remove dynamic policy and set claims in jwt handler * cleanup * change serversettings policy to not need a claim * Add test to checkadmin verification * revert server setting claim removal * fix test * switch back to claim * unit test fixes * try fix build with weird references to csprojes * start fixing rebase * remove https requirement to handle tor * reformat tests correctly * fix csproj * fix ut formatting * PR Changes * do not show selenium browser
46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using System.IO;
|
|
using System.Security.Cryptography;
|
|
using BTCPayServer.Configuration;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using NETCore.Encrypt.Extensions.Internal;
|
|
|
|
namespace BTCPayServer
|
|
{
|
|
public static class OpenIddictExtensions
|
|
{
|
|
private static SecurityKey _key = null;
|
|
public static SecurityKey GetSigningKey(IConfiguration configuration)
|
|
{
|
|
if (_key != null)
|
|
{
|
|
return _key;
|
|
}
|
|
var file = Path.Combine(configuration.GetDataDir(), "rsaparams");
|
|
|
|
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048);
|
|
RsaSecurityKey key = null;
|
|
|
|
if (File.Exists(file))
|
|
{
|
|
RSA.FromXmlString2(File.ReadAllText(file));
|
|
}
|
|
else
|
|
{
|
|
var contents = RSA.ToXmlString2(true);
|
|
File.WriteAllText(file, contents);
|
|
}
|
|
|
|
RSAParameters KeyParam = RSA.ExportParameters(true);
|
|
_key = new RsaSecurityKey(KeyParam);
|
|
return _key;
|
|
}
|
|
public static OpenIddictServerBuilder ConfigureSigningKey(this OpenIddictServerBuilder builder,
|
|
IConfiguration configuration)
|
|
{
|
|
return builder.AddSigningKey(GetSigningKey(configuration));
|
|
}
|
|
}
|
|
}
|