mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: allow unauthenticated users to perform domain name lookups
This commit is contained in:
33
src/Security/Voter/RdapLookupVoter.php
Normal file
33
src/Security/Voter/RdapLookupVoter.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Security\Voter;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
class RdapLookupVoter extends Voter
|
||||
{
|
||||
public const string ATTRIBUTE = 'CAN_RDAP_LOOKUP';
|
||||
|
||||
public function __construct(
|
||||
private readonly ParameterBagInterface $parameterBag,
|
||||
private readonly Security $security,
|
||||
) {
|
||||
}
|
||||
|
||||
protected function supports(string $attribute, mixed $subject): bool
|
||||
{
|
||||
return self::ATTRIBUTE === $attribute;
|
||||
}
|
||||
|
||||
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
|
||||
{
|
||||
if ($this->security->isGranted('IS_AUTHENTICATED_FULLY')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->parameterBag->get('public_rdap_lookup_enabled');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user