mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 09:45:29 +00:00
feat: limit the maximum number of webhooks per Watchlist
This commit is contained in:
parent
050c82bea9
commit
e1e54d9e26
1
.env
1
.env
@ -70,3 +70,4 @@ OAUTH_SCOPE=
|
|||||||
LIMITED_FEATURES=false
|
LIMITED_FEATURES=false
|
||||||
LIMIT_MAX_WATCHLIST=0
|
LIMIT_MAX_WATCHLIST=0
|
||||||
LIMIT_MAX_WATCHLIST_DOMAINS=0
|
LIMIT_MAX_WATCHLIST_DOMAINS=0
|
||||||
|
LIMIT_MAX_WATCHLIST_WEBHOOKS=0
|
||||||
|
|||||||
@ -12,6 +12,7 @@ parameters:
|
|||||||
limited_features: '%env(bool:LIMITED_FEATURES)%'
|
limited_features: '%env(bool:LIMITED_FEATURES)%'
|
||||||
limit_max_watchlist: '%env(int:LIMIT_MAX_WATCHLIST)%'
|
limit_max_watchlist: '%env(int:LIMIT_MAX_WATCHLIST)%'
|
||||||
limit_max_watchlist_domains: '%env(int:LIMIT_MAX_WATCHLIST_DOMAINS)%'
|
limit_max_watchlist_domains: '%env(int:LIMIT_MAX_WATCHLIST_DOMAINS)%'
|
||||||
|
limit_max_watchlist_webhooks: '%env(int:LIMIT_MAX_WATCHLIST_DOMAINS)%'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# default configuration for services in *this* file
|
# default configuration for services in *this* file
|
||||||
|
|||||||
@ -102,7 +102,7 @@ class WatchListController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
if ($this->getParameter('limited_features')) {
|
if ($this->getParameter('limited_features')) {
|
||||||
if ($watchList->getDomains()->count() > (int) $this->getParameter('limit_max_watchlist_domains')) {
|
if ($watchList->getDomains()->count() > (int) $this->getParameter('limit_max_watchlist_domains')) {
|
||||||
$this->logger->notice('User {username} tried to create a Watchlist. The maximum number of domains has been reached for this Watchlist', [
|
$this->logger->notice('User {username} tried to create a Watchlist. The maximum number of domains has been reached.', [
|
||||||
'username' => $user->getUserIdentifier(),
|
'username' => $user->getUserIdentifier(),
|
||||||
]);
|
]);
|
||||||
throw new AccessDeniedHttpException('You have exceeded the maximum number of domain names allowed in this Watchlist');
|
throw new AccessDeniedHttpException('You have exceeded the maximum number of domain names allowed in this Watchlist');
|
||||||
@ -132,6 +132,13 @@ class WatchListController extends AbstractController
|
|||||||
throw new AccessDeniedHttpException("It is forbidden to register the same domain name twice in your watchlists with limited mode ($ldhName)");
|
throw new AccessDeniedHttpException("It is forbidden to register the same domain name twice in your watchlists with limited mode ($ldhName)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null !== $watchList->getWebhookDsn() && count($watchList->getWebhookDsn()) > (int) $this->getParameter('limit_max_watchlist_webhooks')) {
|
||||||
|
$this->logger->notice('User {username} tried to create a Watchlist. The maximum number of webhooks has been reached.', [
|
||||||
|
'username' => $user->getUserIdentifier(),
|
||||||
|
]);
|
||||||
|
throw new AccessDeniedHttpException('You have exceeded the maximum number of webhooks allowed in this Watchlist');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
@ -211,6 +218,13 @@ class WatchListController extends AbstractController
|
|||||||
throw new AccessDeniedHttpException("It is forbidden to register the same domain name twice in your watchlists with limited mode ($ldhName)");
|
throw new AccessDeniedHttpException("It is forbidden to register the same domain name twice in your watchlists with limited mode ($ldhName)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null !== $watchList->getWebhookDsn() && count($watchList->getWebhookDsn()) > (int) $this->getParameter('limit_max_watchlist_webhooks')) {
|
||||||
|
$this->logger->notice('User {username} tried to update a Watchlist. The maximum number of webhooks has been reached.', [
|
||||||
|
'username' => $user->getUserIdentifier(),
|
||||||
|
]);
|
||||||
|
throw new AccessDeniedHttpException('You have exceeded the maximum number of webhooks allowed in this Watchlist');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->info('User {username} updates a Watchlist ({token}).', [
|
$this->logger->info('User {username} updates a Watchlist ({token}).', [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user