1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 21:18:13 -05:00

stripe webhook key from billing settings

This commit is contained in:
Kyle Spearrin 2017-04-26 14:29:25 -04:00
parent 91af4e12c7
commit 398a4d8e46
4 changed files with 39 additions and 3 deletions

View File

@ -0,0 +1,7 @@
namespace Bit.Billing
{
public class BillingSettings
{
public virtual string StripeWebhookKey { get; set; }
}
}

View File

@ -1,14 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
namespace Bit.Billing.Controllers
{
[Route("stripe")]
public class StripeController : Controller
{
[HttpPost("webhook")]
public void PostWebhook([FromBody]dynamic body, [FromQuery] string key)
{
private readonly BillingSettings _billingSettings;
public StripeController(IOptions<BillingSettings> billingSettings)
{
_billingSettings = billingSettings?.Value;
}
[HttpPost("webhook")]
public IActionResult PostWebhook([FromBody]dynamic body, [FromQuery] string key)
{
if(key != _billingSettings.StripeWebhookKey)
{
return new BadRequestResult();
}
return new OkResult();
}
}
}

View File

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Bit.Core;
namespace Bit.Billing
{
@ -33,6 +34,15 @@ namespace Bit.Billing
public void ConfigureServices(IServiceCollection services)
{
// Options
services.AddOptions();
// Settings
//var globalSettings = new GlobalSettings();
//ConfigurationBinder.Bind(Configuration.GetSection("GlobalSettings"), globalSettings);
//services.AddSingleton(s => globalSettings);
services.Configure<BillingSettings>(Configuration.GetSection("BillingSettings"));
services.AddMvc();
}

View File

@ -4,5 +4,11 @@
"LogLevel": {
"Default": "Warning"
}
},
"globalSettings": {
},
"billingSettings": {
"stripeWebhookKey": "SECRET"
}
}