vendor/nellapp/sdk-bundle/src/Developers/Security/Voter/PlatformScopeVoter.php line 9

Open in your IDE?
  1. <?php
  2. namespace Nellapp\Bundle\SDKBundle\Developers\Security\Voter;
  3. use Nellapp\Bundle\SDKBundle\Developers\Security\Authorization\ScopeAuthorisationService;
  4. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  5. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  6. class PlatformScopeVoter extends Voter
  7. {
  8. public function __construct(
  9. private readonly ScopeAuthorisationService $scopeAuthorisationService,
  10. ) {
  11. }
  12. public function supportsType(string $subjectType): bool
  13. {
  14. return true;
  15. }
  16. public function supportsAttribute(mixed $attribute): bool
  17. {
  18. return is_string($attribute) && str_starts_with($attribute, 'platform:');
  19. }
  20. protected function supports($attribute, $subject): bool
  21. {
  22. return $this->supportsAttribute($attribute) && $this->supportsType('');
  23. }
  24. protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
  25. {
  26. return $this->scopeAuthorisationService->canAccessPlatformScope($attribute);
  27. }
  28. }