1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-26 18:21:02 +00:00

Add IsGranted to import controllers

This commit is contained in:
Yassine Guedidi 2025-03-11 00:54:02 +01:00
parent e3dc63f739
commit 9499b062d0
20 changed files with 71 additions and 17 deletions

View file

@ -2,6 +2,7 @@
namespace Wallabag\Controller\Import;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -14,6 +15,7 @@ abstract class BrowserController extends AbstractController
{
/**
* @Route("/import/browser", name="import_browser", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*
* @return Response
*/

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -27,6 +28,7 @@ class ChromeController extends BrowserController
/**
* @Route("/import/chrome", name="import_chrome", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -25,6 +26,7 @@ class DeliciousController extends AbstractController
/**
* @Route("/import/delicious", name="import_delicious", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, DeliciousImport $delicious, Config $craueConfig, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -27,6 +28,7 @@ class ElcuratorController extends WallabagController
/**
* @Route("/import/elcurator", name="import_elcurator", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -27,6 +28,7 @@ class FirefoxController extends BrowserController
/**
* @Route("/import/firefox", name="import_firefox", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{

View file

@ -2,6 +2,7 @@
namespace Wallabag\Controller\Import;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@ -14,6 +15,7 @@ abstract class HtmlController extends AbstractController
{
/**
* @Route("/import/html", name="import_html", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*
* @return Response
*/

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use Predis\Client;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Wallabag\Consumer\RabbitMQConsumerTotalProxy;
@ -21,6 +22,7 @@ class ImportController extends AbstractController
/**
* @Route("/import/", name="import", methods={"GET"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function importAction(ImportChain $importChain)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -25,6 +26,7 @@ class InstapaperController extends AbstractController
/**
* @Route("/import/instapaper", name="import_instapaper", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, InstapaperImport $instapaper, Config $craueConfig, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -25,6 +26,7 @@ class OmnivoreController extends AbstractController
/**
* @Route("/import/omnivore", name="import_omnivore", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, OmnivoreImport $omnivore, Config $craueConfig, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -25,6 +26,7 @@ class PinboardController extends AbstractController
/**
* @Route("/import/pinboard", name="import_pinboard", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, PinboardImport $pinboard, Config $craueConfig, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
@ -31,6 +32,7 @@ class PocketController extends AbstractController
/**
* @Route("/import/pocket", name="import_pocket", methods={"GET"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(PocketImport $pocketImport)
{
@ -52,6 +54,7 @@ class PocketController extends AbstractController
/**
* @Route("/import/pocket/auth", name="import_pocket_auth", methods={"POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function authAction(Request $request, PocketImport $pocketImport)
{
@ -82,6 +85,7 @@ class PocketController extends AbstractController
/**
* @Route("/import/pocket/callback", name="import_pocket_callback", methods={"GET"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function callbackAction(PocketImport $pocketImport, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -27,6 +28,7 @@ class PocketHtmlController extends HtmlController
/**
* @Route("/import/pocket_html", name="import_pocket_html", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -25,6 +26,7 @@ class ReadabilityController extends AbstractController
/**
* @Route("/import/readability", name="import_readability", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, ReadabilityImport $readability, Config $craueConfig, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -27,6 +28,7 @@ class ShaarliController extends HtmlController
/**
* @Route("/import/shaarli", name="import_shaarli", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -27,6 +28,7 @@ class WallabagV1Controller extends WallabagController
/**
* @Route("/import/wallabag-v1", name="import_wallabag_v1", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{

View file

@ -4,6 +4,7 @@ namespace Wallabag\Controller\Import;
use Craue\ConfigBundle\Util\Config;
use OldSound\RabbitMqBundle\RabbitMq\Producer as RabbitMqProducer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
@ -27,6 +28,7 @@ class WallabagV2Controller extends WallabagController
/**
* @Route("/import/wallabag-v2", name="import_wallabag_v2", methods={"GET", "POST"})
* @IsGranted("IMPORT_ENTRIES")
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{

View file

@ -12,6 +12,7 @@ class MainVoter extends Voter
public const CREATE_ENTRIES = 'CREATE_ENTRIES';
public const EDIT_ENTRIES = 'EDIT_ENTRIES';
public const EXPORT_ENTRIES = 'EXPORT_ENTRIES';
public const IMPORT_ENTRIES = 'IMPORT_ENTRIES';
public const LIST_SITE_CREDENTIALS = 'LIST_SITE_CREDENTIALS';
public const CREATE_SITE_CREDENTIALS = 'CREATE_SITE_CREDENTIALS';
@ -28,7 +29,7 @@ class MainVoter extends Voter
return false;
}
if (!\in_array($attribute, [self::LIST_ENTRIES, self::CREATE_ENTRIES, self::EDIT_ENTRIES, self::EXPORT_ENTRIES, self::LIST_SITE_CREDENTIALS, self::CREATE_SITE_CREDENTIALS], true)) {
if (!\in_array($attribute, [self::LIST_ENTRIES, self::CREATE_ENTRIES, self::EDIT_ENTRIES, self::EXPORT_ENTRIES, self::IMPORT_ENTRIES, self::LIST_SITE_CREDENTIALS, self::CREATE_SITE_CREDENTIALS], true)) {
return false;
}
@ -42,6 +43,7 @@ class MainVoter extends Voter
case self::CREATE_ENTRIES:
case self::EDIT_ENTRIES:
case self::EXPORT_ENTRIES:
case self::IMPORT_ENTRIES:
case self::LIST_SITE_CREDENTIALS:
case self::CREATE_SITE_CREDENTIALS:
return $this->security->isGranted('ROLE_USER');