mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Disable API endpoints.
This commit is contained in:
parent
4e6fc8e2a2
commit
e4d91aa337
@ -36,6 +36,7 @@ use Illuminate\Support\Facades\Log;
|
|||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AttemptController
|
* Class AttemptController
|
||||||
@ -69,7 +70,12 @@ class AttemptController extends Controller
|
|||||||
if ($message->webhook_id !== $webhook->id) {
|
if ($message->webhook_id !== $webhook->id) {
|
||||||
throw new FireflyException('200040: Webhook and webhook message are no match');
|
throw new FireflyException('200040: Webhook and webhook message are no match');
|
||||||
}
|
}
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
Log::channel('audit')->info(sprintf('User lists webhook attempts of webhook #%d and message #%d.', $webhook->id, $message->id));
|
Log::channel('audit')->info(sprintf('User lists webhook attempts of webhook #%d and message #%d.', $webhook->id, $message->id));
|
||||||
|
|
||||||
|
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
$pageSize = $this->parameters->get('limit');
|
$pageSize = $this->parameters->get('limit');
|
||||||
$collection = $this->repository->getAttempts($message);
|
$collection = $this->repository->getAttempts($message);
|
||||||
@ -107,6 +113,12 @@ class AttemptController extends Controller
|
|||||||
throw new FireflyException('200041: Webhook message and webhook attempt are no match');
|
throw new FireflyException('200041: Webhook message and webhook attempt are no match');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::channel('audit')->info(sprintf('User views single webhook attempt #%d of webhook #%d and message #%d.', $attempt->id, $webhook->id, $message->id));
|
||||||
|
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
/** @var WebhookAttemptTransformer $transformer */
|
/** @var WebhookAttemptTransformer $transformer */
|
||||||
|
@ -32,6 +32,7 @@ use FireflyIII\Models\WebhookMessage;
|
|||||||
use FireflyIII\Repositories\Webhook\WebhookRepositoryInterface;
|
use FireflyIII\Repositories\Webhook\WebhookRepositoryInterface;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DestroyController
|
* Class DestroyController
|
||||||
@ -61,6 +62,10 @@ class DestroyController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(Webhook $webhook): JsonResponse
|
public function destroy(Webhook $webhook): JsonResponse
|
||||||
{
|
{
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
Log::channel('audit')->info(sprintf('User destroys webhook #%d.', $webhook->id));
|
Log::channel('audit')->info(sprintf('User destroys webhook #%d.', $webhook->id));
|
||||||
$this->repository->destroy($webhook);
|
$this->repository->destroy($webhook);
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
@ -84,8 +89,14 @@ class DestroyController extends Controller
|
|||||||
if ($attempt->webhook_message_id !== $message->id) {
|
if ($attempt->webhook_message_id !== $message->id) {
|
||||||
throw new FireflyException('200041: Webhook message and webhook attempt are no match');
|
throw new FireflyException('200041: Webhook message and webhook attempt are no match');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
Log::channel('audit')->info(sprintf('User destroys webhook #%d, message #%d, attempt #%d.', $webhook->id, $message->id, $attempt->id));
|
Log::channel('audit')->info(sprintf('User destroys webhook #%d, message #%d, attempt #%d.', $webhook->id, $message->id, $attempt->id));
|
||||||
|
|
||||||
|
|
||||||
$this->repository->destroyAttempt($attempt);
|
$this->repository->destroyAttempt($attempt);
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
@ -106,6 +117,11 @@ class DestroyController extends Controller
|
|||||||
if ($message->webhook_id !== $webhook->id) {
|
if ($message->webhook_id !== $webhook->id) {
|
||||||
throw new FireflyException('200040: Webhook and webhook message are no match');
|
throw new FireflyException('200040: Webhook and webhook message are no match');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->repository->destroyMessage($message);
|
$this->repository->destroyMessage($message);
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ use Illuminate\Support\Facades\Log;
|
|||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MessageController
|
* Class MessageController
|
||||||
@ -65,6 +66,9 @@ class MessageController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Webhook $webhook): JsonResponse
|
public function index(Webhook $webhook): JsonResponse
|
||||||
{
|
{
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
Log::channel('audit')->info(sprintf('User views messages of webhook #%d.', $webhook->id));
|
Log::channel('audit')->info(sprintf('User views messages of webhook #%d.', $webhook->id));
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
$pageSize = $this->parameters->get('limit');
|
$pageSize = $this->parameters->get('limit');
|
||||||
@ -100,6 +104,10 @@ class MessageController extends Controller
|
|||||||
if ($message->webhook_id !== $webhook->id) {
|
if ($message->webhook_id !== $webhook->id) {
|
||||||
throw new FireflyException('200040: Webhook and webhook message are no match');
|
throw new FireflyException('200040: Webhook and webhook message are no match');
|
||||||
}
|
}
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
Log::channel('audit')->info(sprintf('User views message #%d of webhook #%d.', $message->id, $webhook->id));
|
Log::channel('audit')->info(sprintf('User views message #%d of webhook #%d.', $message->id, $webhook->id));
|
||||||
|
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
@ -38,6 +38,7 @@ use Illuminate\Support\Facades\Log;
|
|||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ShowController
|
* Class ShowController
|
||||||
@ -70,6 +71,10 @@ class ShowController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(): JsonResponse
|
public function index(): JsonResponse
|
||||||
{
|
{
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
Log::channel('audit')->info('User views all webhooks.');
|
Log::channel('audit')->info('User views all webhooks.');
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
$collection = $this->repository->all();
|
$collection = $this->repository->all();
|
||||||
@ -99,6 +104,10 @@ class ShowController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(Webhook $webhook): JsonResponse
|
public function show(Webhook $webhook): JsonResponse
|
||||||
{
|
{
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
Log::channel('audit')->info(sprintf('User views webhook #%d.', $webhook->id));
|
Log::channel('audit')->info(sprintf('User views webhook #%d.', $webhook->id));
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
@ -118,6 +127,10 @@ class ShowController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function triggerTransaction(Webhook $webhook, TransactionGroup $group): JsonResponse
|
public function triggerTransaction(Webhook $webhook, TransactionGroup $group): JsonResponse
|
||||||
{
|
{
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
app('log')->debug(sprintf('Now in triggerTransaction(%d, %d)', $webhook->id, $group->id));
|
app('log')->debug(sprintf('Now in triggerTransaction(%d, %d)', $webhook->id, $group->id));
|
||||||
Log::channel('audit')->info(sprintf('User triggers webhook #%d on transaction group #%d.', $webhook->id, $group->id));
|
Log::channel('audit')->info(sprintf('User triggers webhook #%d on transaction group #%d.', $webhook->id, $group->id));
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ use FireflyIII\Transformers\WebhookTransformer;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class StoreController
|
* Class StoreController
|
||||||
@ -58,6 +59,10 @@ class StoreController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(CreateRequest $request): JsonResponse
|
public function store(CreateRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$data = $request->getData();
|
$data = $request->getData();
|
||||||
$webhook = $this->repository->store($data);
|
$webhook = $this->repository->store($data);
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
@ -29,6 +29,7 @@ use FireflyIII\Models\Webhook;
|
|||||||
use FireflyIII\Repositories\Webhook\WebhookRepositoryInterface;
|
use FireflyIII\Repositories\Webhook\WebhookRepositoryInterface;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SubmitController
|
* Class SubmitController
|
||||||
@ -56,6 +57,10 @@ class SubmitController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function submit(Webhook $webhook): JsonResponse
|
public function submit(Webhook $webhook): JsonResponse
|
||||||
{
|
{
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
Log::channel('audit')->info(sprintf('User submits webhook #%d', $webhook->id));
|
Log::channel('audit')->info(sprintf('User submits webhook #%d', $webhook->id));
|
||||||
// count messages that can be sent.
|
// count messages that can be sent.
|
||||||
$messages = $this->repository->getReadyMessages($webhook);
|
$messages = $this->repository->getReadyMessages($webhook);
|
||||||
|
@ -31,6 +31,7 @@ use FireflyIII\Transformers\WebhookTransformer;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class UpdateController
|
* Class UpdateController
|
||||||
@ -58,6 +59,10 @@ class UpdateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(Webhook $webhook, UpdateRequest $request): JsonResponse
|
public function update(Webhook $webhook, UpdateRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
if(false === config('firefly.allow_webhooks')) {
|
||||||
|
throw new NotFoundHttpException('Webhooks are not enabled.');
|
||||||
|
}
|
||||||
|
|
||||||
$data = $request->getData();
|
$data = $request->getData();
|
||||||
$webhook = $this->repository->update($webhook, $data);
|
$webhook = $this->repository->update($webhook, $data);
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
Loading…
Reference in New Issue
Block a user