Enable CORS and fix small doc error

This commit is contained in:
Kukks
2020-06-30 08:26:19 +02:00
parent aeb90a3674
commit 82af723f1f
10 changed files with 26 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ using BTCPayServer.Data;
using BTCPayServer.Security; using BTCPayServer.Security;
using BTCPayServer.Security.GreenField; using BTCPayServer.Security.GreenField;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NBitcoin; using NBitcoin;
@@ -15,6 +16,7 @@ namespace BTCPayServer.Controllers.GreenField
{ {
[ApiController] [ApiController]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.GreenfieldAPIKeys)] [Authorize(AuthenticationSchemes = AuthenticationSchemes.GreenfieldAPIKeys)]
[EnableCors(CorsPolicies.All)]
public class ApiKeysController : ControllerBase public class ApiKeysController : ControllerBase
{ {
private readonly APIKeyRepository _apiKeyRepository; private readonly APIKeyRepository _apiKeyRepository;

View File

@@ -1,11 +1,13 @@
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.HostedServices; using BTCPayServer.HostedServices;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace BTCPayServer.Controllers.GreenField namespace BTCPayServer.Controllers.GreenField
{ {
[Controller] [Controller]
[EnableCors(CorsPolicies.All)]
public class HealthController : ControllerBase public class HealthController : ControllerBase
{ {
[AllowAnonymous] [AllowAnonymous]

View File

@@ -7,6 +7,7 @@ using BTCPayServer.Lightning;
using BTCPayServer.Security; using BTCPayServer.Security;
using BTCPayServer.Services; using BTCPayServer.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace BTCPayServer.Controllers.GreenField namespace BTCPayServer.Controllers.GreenField
@@ -14,6 +15,7 @@ namespace BTCPayServer.Controllers.GreenField
[ApiController] [ApiController]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[LightningUnavailableExceptionFilter] [LightningUnavailableExceptionFilter]
[EnableCors(CorsPolicies.All)]
public class InternalLightningNodeApiController : LightningNodeApiController public class InternalLightningNodeApiController : LightningNodeApiController
{ {
private readonly BTCPayServerOptions _btcPayServerOptions; private readonly BTCPayServerOptions _btcPayServerOptions;

View File

@@ -11,6 +11,7 @@ using BTCPayServer.Payments.Lightning;
using BTCPayServer.Security; using BTCPayServer.Security;
using BTCPayServer.Services; using BTCPayServer.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace BTCPayServer.Controllers.GreenField namespace BTCPayServer.Controllers.GreenField
@@ -18,6 +19,7 @@ namespace BTCPayServer.Controllers.GreenField
[ApiController] [ApiController]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[LightningUnavailableExceptionFilter] [LightningUnavailableExceptionFilter]
[EnableCors(CorsPolicies.All)]
public class StoreLightningNodeApiController : LightningNodeApiController public class StoreLightningNodeApiController : LightningNodeApiController
{ {
private readonly BTCPayServerOptions _btcPayServerOptions; private readonly BTCPayServerOptions _btcPayServerOptions;

View File

@@ -9,6 +9,7 @@ using BTCPayServer.Security;
using BTCPayServer.Services.PaymentRequests; using BTCPayServer.Services.PaymentRequests;
using BTCPayServer.Services.Rates; using BTCPayServer.Services.Rates;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using PaymentRequestData = BTCPayServer.Data.PaymentRequestData; using PaymentRequestData = BTCPayServer.Data.PaymentRequestData;
@@ -16,6 +17,7 @@ namespace BTCPayServer.Controllers.GreenField
{ {
[ApiController] [ApiController]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[EnableCors(CorsPolicies.All)]
public class GreenFieldPaymentRequestsController : ControllerBase public class GreenFieldPaymentRequestsController : ControllerBase
{ {
private readonly PaymentRequestRepository _paymentRequestRepository; private readonly PaymentRequestRepository _paymentRequestRepository;

View File

@@ -12,6 +12,7 @@ using BTCPayServer.Security;
using BTCPayServer.Services; using BTCPayServer.Services;
using BTCPayServer.Services.Rates; using BTCPayServer.Services.Rates;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -20,6 +21,7 @@ namespace BTCPayServer.Controllers.GreenField
{ {
[ApiController] [ApiController]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[EnableCors(CorsPolicies.All)]
public class GreenfieldPullPaymentController : ControllerBase public class GreenfieldPullPaymentController : ControllerBase
{ {
private readonly PullPaymentHostedService _pullPaymentService; private readonly PullPaymentHostedService _pullPaymentService;

View File

@@ -8,6 +8,7 @@ using BTCPayServer.Services;
using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Stores; using BTCPayServer.Services.Stores;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NBXplorer.Models; using NBXplorer.Models;
@@ -15,6 +16,7 @@ using NBXplorer.Models;
namespace BTCPayServer.Controllers.GreenField namespace BTCPayServer.Controllers.GreenField
{ {
[ApiController] [ApiController]
[EnableCors(CorsPolicies.All)]
public class GreenFieldServerInfoController : Controller public class GreenFieldServerInfoController : Controller
{ {
private readonly BTCPayServerEnvironment _env; private readonly BTCPayServerEnvironment _env;

View File

@@ -8,6 +8,7 @@ using BTCPayServer.Data;
using BTCPayServer.Security; using BTCPayServer.Security;
using BTCPayServer.Services.Stores; using BTCPayServer.Services.Stores;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -15,6 +16,7 @@ namespace BTCPayServer.Controllers.GreenField
{ {
[ApiController] [ApiController]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[EnableCors(CorsPolicies.All)]
public class GreenFieldController : ControllerBase public class GreenFieldController : ControllerBase
{ {
private readonly StoreRepository _storeRepository; private readonly StoreRepository _storeRepository;

View File

@@ -11,6 +11,7 @@ using BTCPayServer.Security;
using BTCPayServer.Security.GreenField; using BTCPayServer.Security.GreenField;
using BTCPayServer.Services; using BTCPayServer.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@@ -20,6 +21,7 @@ namespace BTCPayServer.Controllers.GreenField
{ {
[ApiController] [ApiController]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
[EnableCors(CorsPolicies.All)]
public class UsersController : ControllerBase public class UsersController : ControllerBase
{ {
private readonly UserManager<ApplicationUser> _userManager; private readonly UserManager<ApplicationUser> _userManager;

View File

@@ -41,7 +41,13 @@
"description": "View information about the current API key", "description": "View information about the current API key",
"responses": { "responses": {
"200": { "200": {
"description": "The key has been deleted" "description": "Information about the current api key",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiKeyData"
}
}
} }
}, },
"security": [ "security": [