Use good rng for generating API keys

This commit is contained in:
nicolas.dorier 2020-03-10 21:30:46 +09:00
parent 691a8d6fd8
commit 153992a458
No known key found for this signature in database
GPG key ID: 6618763EF09186FE

View file

@ -10,6 +10,8 @@ using BTCPayServer.Security;
using BTCPayServer.Security.APIKeys;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NBitcoin;
using NBitcoin.DataEncoders;
using NSwag.Annotations;
namespace BTCPayServer.Controllers
@ -247,7 +249,7 @@ namespace BTCPayServer.Controllers
{
var key = new APIKeyData()
{
Id = Guid.NewGuid().ToString().Replace("-", string.Empty, StringComparison.OrdinalIgnoreCase),
Id = Encoders.Hex.EncodeData(RandomUtils.GetBytes(20)),
Type = APIKeyType.Permanent,
UserId = _userManager.GetUserId(User),
Label = viewModel.Label