diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-06-20 16:40:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-20 16:40:48 +0200 |
commit | 80784b782becfaa297e6d9cbb0584e27739cffc8 (patch) | |
tree | fc201969597b16070d890b0703568618a81a76bc | |
parent | 604cca1f4247f9f905e57b9276cf2543cfa41a5d (diff) | |
parent | f44dba22fc1a566cb156d9e6eda5afc353163eda (diff) | |
download | wallabag-80784b782becfaa297e6d9cbb0584e27739cffc8.tar.gz wallabag-80784b782becfaa297e6d9cbb0584e27739cffc8.tar.zst wallabag-80784b782becfaa297e6d9cbb0584e27739cffc8.zip |
Merge pull request #2683 from wallabag/credentials-in-db
Store credentials in DB
41 files changed, 1605 insertions, 39 deletions
@@ -56,3 +56,4 @@ app/Resources/build/ | |||
56 | # Test-generated files | 56 | # Test-generated files |
57 | admin-export.json | 57 | admin-export.json |
58 | specialexport.json | 58 | specialexport.json |
59 | /data/site-credentials-secret-key.txt | ||
diff --git a/app/DoctrineMigrations/Version20170501115751.php b/app/DoctrineMigrations/Version20170501115751.php new file mode 100644 index 00000000..7f068eb8 --- /dev/null +++ b/app/DoctrineMigrations/Version20170501115751.php | |||
@@ -0,0 +1,61 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Add site credential table to store username & password for some website (behind authentication or paywall) | ||
12 | */ | ||
13 | class Version20170501115751 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | private function getTable($tableName) | ||
26 | { | ||
27 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @param Schema $schema | ||
32 | */ | ||
33 | public function up(Schema $schema) | ||
34 | { | ||
35 | $this->skipIf($schema->hasTable($this->getTable('site_credential')), 'It seems that you already played this migration.'); | ||
36 | |||
37 | $table = $schema->createTable($this->getTable('site_credential')); | ||
38 | $table->addColumn('id', 'integer', ['autoincrement' => true]); | ||
39 | $table->addColumn('user_id', 'integer'); | ||
40 | $table->addColumn('host', 'string', ['length' => 255]); | ||
41 | $table->addColumn('username', 'text'); | ||
42 | $table->addColumn('password', 'text'); | ||
43 | $table->addColumn('createdAt', 'datetime'); | ||
44 | $table->addIndex(['user_id'], 'idx_user'); | ||
45 | $table->setPrimaryKey(['id']); | ||
46 | $table->addForeignKeyConstraint($this->getTable('user'), ['user_id'], ['id'], [], 'fk_user'); | ||
47 | |||
48 | if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) { | ||
49 | $schema->dropSequence('site_credential_id_seq'); | ||
50 | $schema->createSequence('site_credential_id_seq'); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * @param Schema $schema | ||
56 | */ | ||
57 | public function down(Schema $schema) | ||
58 | { | ||
59 | $schema->dropTable($this->getTable('site_credential')); | ||
60 | } | ||
61 | } | ||
diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 914fb1ef..b3fe11c8 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist | |||
@@ -60,6 +60,3 @@ parameters: | |||
60 | redis_port: 6379 | 60 | redis_port: 6379 |
61 | redis_path: null | 61 | redis_path: null |
62 | redis_password: null | 62 | redis_password: null |
63 | |||
64 | # sites credentials | ||
65 | sites_credentials: {} | ||
diff --git a/app/config/wallabag.yml b/app/config/wallabag.yml index 51b7e4e3..b45934e4 100644 --- a/app/config/wallabag.yml +++ b/app/config/wallabag.yml | |||
@@ -26,6 +26,7 @@ wallabag_core: | |||
26 | fetching_error_message: | | 26 | fetching_error_message: | |
27 | wallabag can't retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>. | 27 | wallabag can't retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>. |
28 | api_limit_mass_actions: 10 | 28 | api_limit_mass_actions: 10 |
29 | encryption_key_path: "%kernel.root_dir%/../data/site-credentials-secret-key.txt" | ||
29 | default_internal_settings: | 30 | default_internal_settings: |
30 | - | 31 | - |
31 | name: share_public | 32 | name: share_public |
diff --git a/composer.json b/composer.json index 0a170c16..7428f688 100644 --- a/composer.json +++ b/composer.json | |||
@@ -73,7 +73,7 @@ | |||
73 | "kphoen/rulerz-bundle": "~0.13", | 73 | "kphoen/rulerz-bundle": "~0.13", |
74 | "guzzlehttp/guzzle": "^5.3.1", | 74 | "guzzlehttp/guzzle": "^5.3.1", |
75 | "doctrine/doctrine-migrations-bundle": "^1.0", | 75 | "doctrine/doctrine-migrations-bundle": "^1.0", |
76 | "paragonie/random_compat": "~1.0", | 76 | "paragonie/random_compat": "~2.0", |
77 | "craue/config-bundle": "~2.0", | 77 | "craue/config-bundle": "~2.0", |
78 | "mnapoli/piwik-twig-extension": "^1.0", | 78 | "mnapoli/piwik-twig-extension": "^1.0", |
79 | "ocramius/proxy-manager": "1.*", | 79 | "ocramius/proxy-manager": "1.*", |
@@ -83,7 +83,8 @@ | |||
83 | "javibravo/simpleue": "^1.0", | 83 | "javibravo/simpleue": "^1.0", |
84 | "symfony/dom-crawler": "^3.1", | 84 | "symfony/dom-crawler": "^3.1", |
85 | "friendsofsymfony/jsrouting-bundle": "^1.6", | 85 | "friendsofsymfony/jsrouting-bundle": "^1.6", |
86 | "bdunogier/guzzle-site-authenticator": "^1.0.0@dev" | 86 | "bdunogier/guzzle-site-authenticator": "^1.0.0@dev", |
87 | "defuse/php-encryption": "^2.1" | ||
87 | }, | 88 | }, |
88 | "require-dev": { | 89 | "require-dev": { |
89 | "doctrine/doctrine-fixtures-bundle": "~2.2", | 90 | "doctrine/doctrine-fixtures-bundle": "~2.2", |
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 0f119377..eb725a59 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php | |||
@@ -313,6 +313,8 @@ class InstallCommand extends ContainerAwareCommand | |||
313 | 313 | ||
314 | $this | 314 | $this |
315 | ->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]); | 315 | ->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]); |
316 | |||
317 | return $this; | ||
316 | } | 318 | } |
317 | 319 | ||
318 | /** | 320 | /** |
diff --git a/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php new file mode 100644 index 00000000..98781dab --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php | |||
@@ -0,0 +1,174 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Controller; | ||
4 | |||
5 | use Symfony\Component\HttpFoundation\Request; | ||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
7 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | ||
8 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
9 | use Wallabag\UserBundle\Entity\User; | ||
10 | use Wallabag\CoreBundle\Entity\SiteCredential; | ||
11 | |||
12 | /** | ||
13 | * SiteCredential controller. | ||
14 | * | ||
15 | * @Route("/site-credentials") | ||
16 | */ | ||
17 | class SiteCredentialController extends Controller | ||
18 | { | ||
19 | /** | ||
20 | * Lists all User entities. | ||
21 | * | ||
22 | * @Route("/", name="site_credentials_index") | ||
23 | * @Method("GET") | ||
24 | */ | ||
25 | public function indexAction() | ||
26 | { | ||
27 | $credentials = $this->get('wallabag_core.site_credential_repository')->findByUser($this->getUser()); | ||
28 | |||
29 | return $this->render('WallabagCoreBundle:SiteCredential:index.html.twig', [ | ||
30 | 'credentials' => $credentials, | ||
31 | ]); | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * Creates a new site credential entity. | ||
36 | * | ||
37 | * @Route("/new", name="site_credentials_new") | ||
38 | * @Method({"GET", "POST"}) | ||
39 | * | ||
40 | * @param Request $request | ||
41 | * | ||
42 | * @return \Symfony\Component\HttpFoundation\Response | ||
43 | */ | ||
44 | public function newAction(Request $request) | ||
45 | { | ||
46 | $credential = new SiteCredential($this->getUser()); | ||
47 | |||
48 | $form = $this->createForm('Wallabag\CoreBundle\Form\Type\SiteCredentialType', $credential); | ||
49 | $form->handleRequest($request); | ||
50 | |||
51 | if ($form->isSubmitted() && $form->isValid()) { | ||
52 | $credential->setUsername($this->get('wallabag_core.helper.crypto_proxy')->crypt($credential->getUsername())); | ||
53 | $credential->setPassword($this->get('wallabag_core.helper.crypto_proxy')->crypt($credential->getPassword())); | ||
54 | |||
55 | $em = $this->getDoctrine()->getManager(); | ||
56 | $em->persist($credential); | ||
57 | $em->flush(); | ||
58 | |||
59 | $this->get('session')->getFlashBag()->add( | ||
60 | 'notice', | ||
61 | $this->get('translator')->trans('flashes.site_credential.notice.added', ['%host%' => $credential->getHost()]) | ||
62 | ); | ||
63 | |||
64 | return $this->redirectToRoute('site_credentials_index'); | ||
65 | } | ||
66 | |||
67 | return $this->render('WallabagCoreBundle:SiteCredential:new.html.twig', [ | ||
68 | 'credential' => $credential, | ||
69 | 'form' => $form->createView(), | ||
70 | ]); | ||
71 | } | ||
72 | |||
73 | /** | ||
74 | * Displays a form to edit an existing site credential entity. | ||
75 | * | ||
76 | * @Route("/{id}/edit", name="site_credentials_edit") | ||
77 | * @Method({"GET", "POST"}) | ||
78 | * | ||
79 | * @param Request $request | ||
80 | * @param SiteCredential $siteCredential | ||
81 | * | ||
82 | * @return \Symfony\Component\HttpFoundation\Response | ||
83 | */ | ||
84 | public function editAction(Request $request, SiteCredential $siteCredential) | ||
85 | { | ||
86 | $this->checkUserAction($siteCredential); | ||
87 | |||
88 | $deleteForm = $this->createDeleteForm($siteCredential); | ||
89 | $editForm = $this->createForm('Wallabag\CoreBundle\Form\Type\SiteCredentialType', $siteCredential); | ||
90 | $editForm->handleRequest($request); | ||
91 | |||
92 | if ($editForm->isSubmitted() && $editForm->isValid()) { | ||
93 | $siteCredential->setUsername($this->get('wallabag_core.helper.crypto_proxy')->crypt($siteCredential->getUsername())); | ||
94 | $siteCredential->setPassword($this->get('wallabag_core.helper.crypto_proxy')->crypt($siteCredential->getPassword())); | ||
95 | |||
96 | $em = $this->getDoctrine()->getManager(); | ||
97 | $em->persist($siteCredential); | ||
98 | $em->flush(); | ||
99 | |||
100 | $this->get('session')->getFlashBag()->add( | ||
101 | 'notice', | ||
102 | $this->get('translator')->trans('flashes.site_credential.notice.updated', ['%host%' => $siteCredential->getHost()]) | ||
103 | ); | ||
104 | |||
105 | return $this->redirectToRoute('site_credentials_index'); | ||
106 | } | ||
107 | |||
108 | return $this->render('WallabagCoreBundle:SiteCredential:edit.html.twig', [ | ||
109 | 'credential' => $siteCredential, | ||
110 | 'edit_form' => $editForm->createView(), | ||
111 | 'delete_form' => $deleteForm->createView(), | ||
112 | ]); | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * Deletes a site credential entity. | ||
117 | * | ||
118 | * @Route("/{id}", name="site_credentials_delete") | ||
119 | * @Method("DELETE") | ||
120 | * | ||
121 | * @param Request $request | ||
122 | * @param SiteCredential $siteCredential | ||
123 | * | ||
124 | * @return \Symfony\Component\HttpFoundation\RedirectResponse | ||
125 | */ | ||
126 | public function deleteAction(Request $request, SiteCredential $siteCredential) | ||
127 | { | ||
128 | $this->checkUserAction($siteCredential); | ||
129 | |||
130 | $form = $this->createDeleteForm($siteCredential); | ||
131 | $form->handleRequest($request); | ||
132 | |||
133 | if ($form->isSubmitted() && $form->isValid()) { | ||
134 | $this->get('session')->getFlashBag()->add( | ||
135 | 'notice', | ||
136 | $this->get('translator')->trans('flashes.site_credential.notice.deleted', ['%host%' => $siteCredential->getHost()]) | ||
137 | ); | ||
138 | |||
139 | $em = $this->getDoctrine()->getManager(); | ||
140 | $em->remove($siteCredential); | ||
141 | $em->flush(); | ||
142 | } | ||
143 | |||
144 | return $this->redirectToRoute('site_credentials_index'); | ||
145 | } | ||
146 | |||
147 | /** | ||
148 | * Creates a form to delete a site credential entity. | ||
149 | * | ||
150 | * @param SiteCredential $siteCredential The site credential entity | ||
151 | * | ||
152 | * @return \Symfony\Component\Form\Form The form | ||
153 | */ | ||
154 | private function createDeleteForm(SiteCredential $siteCredential) | ||
155 | { | ||
156 | return $this->createFormBuilder() | ||
157 | ->setAction($this->generateUrl('site_credentials_delete', ['id' => $siteCredential->getId()])) | ||
158 | ->setMethod('DELETE') | ||
159 | ->getForm() | ||
160 | ; | ||
161 | } | ||
162 | |||
163 | /** | ||
164 | * Check if the logged user can manage the given site credential. | ||
165 | * | ||
166 | * @param SiteCredential $siteCredential The site credential entity | ||
167 | */ | ||
168 | private function checkUserAction(SiteCredential $siteCredential) | ||
169 | { | ||
170 | if (null === $this->getUser() || $this->getUser()->getId() != $siteCredential->getUser()->getId()) { | ||
171 | throw $this->createAccessDeniedException('You can not access this site credential.'); | ||
172 | } | ||
173 | } | ||
174 | } | ||
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php new file mode 100644 index 00000000..866f55a4 --- /dev/null +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php | |||
@@ -0,0 +1,34 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\DataFixtures\ORM; | ||
4 | |||
5 | use Doctrine\Common\DataFixtures\AbstractFixture; | ||
6 | use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | ||
7 | use Doctrine\Common\Persistence\ObjectManager; | ||
8 | use Wallabag\CoreBundle\Entity\SiteCredential; | ||
9 | |||
10 | class LoadSiteCredentialData extends AbstractFixture implements OrderedFixtureInterface | ||
11 | { | ||
12 | /** | ||
13 | * {@inheritdoc} | ||
14 | */ | ||
15 | public function load(ObjectManager $manager) | ||
16 | { | ||
17 | $credential = new SiteCredential($this->getReference('admin-user')); | ||
18 | $credential->setHost('example.com'); | ||
19 | $credential->setUsername('foo'); | ||
20 | $credential->setPassword('bar'); | ||
21 | |||
22 | $manager->persist($credential); | ||
23 | |||
24 | $manager->flush(); | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * {@inheritdoc} | ||
29 | */ | ||
30 | public function getOrder() | ||
31 | { | ||
32 | return 50; | ||
33 | } | ||
34 | } | ||
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php index 33df92d3..a9791f6b 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/Configuration.php | |||
@@ -63,6 +63,8 @@ class Configuration implements ConfigurationInterface | |||
63 | ->end() | 63 | ->end() |
64 | ->end() | 64 | ->end() |
65 | ->end() | 65 | ->end() |
66 | ->scalarNode('encryption_key_path') | ||
67 | ->end() | ||
66 | ->end() | 68 | ->end() |
67 | ; | 69 | ; |
68 | 70 | ||
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php index b4d8a386..532ce238 100644 --- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php +++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php | |||
@@ -29,6 +29,7 @@ class WallabagCoreExtension extends Extension | |||
29 | $container->setParameter('wallabag_core.fetching_error_message_title', $config['fetching_error_message_title']); | 29 | $container->setParameter('wallabag_core.fetching_error_message_title', $config['fetching_error_message_title']); |
30 | $container->setParameter('wallabag_core.api_limit_mass_actions', $config['api_limit_mass_actions']); | 30 | $container->setParameter('wallabag_core.api_limit_mass_actions', $config['api_limit_mass_actions']); |
31 | $container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']); | 31 | $container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']); |
32 | $container->setParameter('wallabag_core.site_credentials.encryption_key_path', $config['encryption_key_path']); | ||
32 | 33 | ||
33 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | 34 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
34 | $loader->load('services.yml'); | 35 | $loader->load('services.yml'); |
diff --git a/src/Wallabag/CoreBundle/Entity/SiteCredential.php b/src/Wallabag/CoreBundle/Entity/SiteCredential.php new file mode 100644 index 00000000..58075e92 --- /dev/null +++ b/src/Wallabag/CoreBundle/Entity/SiteCredential.php | |||
@@ -0,0 +1,195 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Entity; | ||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; | ||
6 | use Symfony\Component\Validator\Constraints as Assert; | ||
7 | use Wallabag\UserBundle\Entity\User; | ||
8 | |||
9 | /** | ||
10 | * SiteCredential. | ||
11 | * | ||
12 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\SiteCredentialRepository") | ||
13 | * @ORM\Table(name="`site_credential`") | ||
14 | * @ORM\HasLifecycleCallbacks() | ||
15 | */ | ||
16 | class SiteCredential | ||
17 | { | ||
18 | /** | ||
19 | * @var int | ||
20 | * | ||
21 | * @ORM\Column(name="id", type="integer") | ||
22 | * @ORM\Id | ||
23 | * @ORM\GeneratedValue(strategy="AUTO") | ||
24 | */ | ||
25 | private $id; | ||
26 | |||
27 | /** | ||
28 | * @var string | ||
29 | * | ||
30 | * @Assert\NotBlank() | ||
31 | * @Assert\Length(max=255) | ||
32 | * @ORM\Column(name="host", type="string", length=255) | ||
33 | */ | ||
34 | private $host; | ||
35 | |||
36 | /** | ||
37 | * @var string | ||
38 | * | ||
39 | * @Assert\NotBlank() | ||
40 | * @ORM\Column(name="username", type="text") | ||
41 | */ | ||
42 | private $username; | ||
43 | |||
44 | /** | ||
45 | * @var string | ||
46 | * | ||
47 | * @Assert\NotBlank() | ||
48 | * @ORM\Column(name="password", type="text") | ||
49 | */ | ||
50 | private $password; | ||
51 | |||
52 | /** | ||
53 | * @var \DateTime | ||
54 | * | ||
55 | * @ORM\Column(name="createdAt", type="datetime") | ||
56 | */ | ||
57 | private $createdAt; | ||
58 | |||
59 | /** | ||
60 | * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="site_credentials") | ||
61 | */ | ||
62 | private $user; | ||
63 | |||
64 | /* | ||
65 | * @param User $user | ||
66 | */ | ||
67 | public function __construct(User $user) | ||
68 | { | ||
69 | $this->user = $user; | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * Get id. | ||
74 | * | ||
75 | * @return int | ||
76 | */ | ||
77 | public function getId() | ||
78 | { | ||
79 | return $this->id; | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * Set host. | ||
84 | * | ||
85 | * @param string $host | ||
86 | * | ||
87 | * @return SiteCredential | ||
88 | */ | ||
89 | public function setHost($host) | ||
90 | { | ||
91 | $this->host = $host; | ||
92 | |||
93 | return $this; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * Get host. | ||
98 | * | ||
99 | * @return string | ||
100 | */ | ||
101 | public function getHost() | ||
102 | { | ||
103 | return $this->host; | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * Set username. | ||
108 | * | ||
109 | * @param string $username | ||
110 | * | ||
111 | * @return SiteCredential | ||
112 | */ | ||
113 | public function setUsername($username) | ||
114 | { | ||
115 | $this->username = $username; | ||
116 | |||
117 | return $this; | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * Get username. | ||
122 | * | ||
123 | * @return string | ||
124 | */ | ||
125 | public function getUsername() | ||
126 | { | ||
127 | return $this->username; | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * Set password. | ||
132 | * | ||
133 | * @param string $password | ||
134 | * | ||
135 | * @return SiteCredential | ||
136 | */ | ||
137 | public function setPassword($password) | ||
138 | { | ||
139 | $this->password = $password; | ||
140 | |||
141 | return $this; | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | * Get password. | ||
146 | * | ||
147 | * @return string | ||
148 | */ | ||
149 | public function getPassword() | ||
150 | { | ||
151 | return $this->password; | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * Set createdAt. | ||
156 | * | ||
157 | * @param \DateTime $createdAt | ||
158 | * | ||
159 | * @return SiteCredential | ||
160 | */ | ||
161 | public function setCreatedAt($createdAt) | ||
162 | { | ||
163 | $this->createdAt = $createdAt; | ||
164 | |||
165 | return $this; | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * Get createdAt. | ||
170 | * | ||
171 | * @return \DateTime | ||
172 | */ | ||
173 | public function getCreatedAt() | ||
174 | { | ||
175 | return $this->createdAt; | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * @return User | ||
180 | */ | ||
181 | public function getUser() | ||
182 | { | ||
183 | return $this->user; | ||
184 | } | ||
185 | |||
186 | /** | ||
187 | * @ORM\PrePersist | ||
188 | */ | ||
189 | public function timestamps() | ||
190 | { | ||
191 | if (is_null($this->createdAt)) { | ||
192 | $this->createdAt = new \DateTime(); | ||
193 | } | ||
194 | } | ||
195 | } | ||
diff --git a/src/Wallabag/CoreBundle/Form/Type/SiteCredentialType.php b/src/Wallabag/CoreBundle/Form/Type/SiteCredentialType.php new file mode 100644 index 00000000..fd409ad2 --- /dev/null +++ b/src/Wallabag/CoreBundle/Form/Type/SiteCredentialType.php | |||
@@ -0,0 +1,44 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Form\Type; | ||
4 | |||
5 | use Symfony\Component\Form\AbstractType; | ||
6 | use Symfony\Component\Form\Extension\Core\Type\PasswordType; | ||
7 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||
8 | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
9 | use Symfony\Component\Form\FormBuilderInterface; | ||
10 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
11 | |||
12 | class SiteCredentialType extends AbstractType | ||
13 | { | ||
14 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
15 | { | ||
16 | $builder | ||
17 | ->add('host', TextType::class, [ | ||
18 | 'label' => 'site_credential.form.host_label', | ||
19 | ]) | ||
20 | ->add('username', TextType::class, [ | ||
21 | 'label' => 'site_credential.form.username_label', | ||
22 | 'data' => '', | ||
23 | ]) | ||
24 | ->add('password', PasswordType::class, [ | ||
25 | 'label' => 'site_credential.form.password_label', | ||
26 | ]) | ||
27 | ->add('save', SubmitType::class, [ | ||
28 | 'label' => 'config.form.save', | ||
29 | ]) | ||
30 | ; | ||
31 | } | ||
32 | |||
33 | public function configureOptions(OptionsResolver $resolver) | ||
34 | { | ||
35 | $resolver->setDefaults([ | ||
36 | 'data_class' => 'Wallabag\CoreBundle\Entity\SiteCredential', | ||
37 | ]); | ||
38 | } | ||
39 | |||
40 | public function getBlockPrefix() | ||
41 | { | ||
42 | return 'site_credential'; | ||
43 | } | ||
44 | } | ||
diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php index 1c56fa9f..a79e6ebe 100644 --- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php +++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php | |||
@@ -6,6 +6,8 @@ use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; | |||
6 | use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder; | 6 | use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder; |
7 | use Graby\SiteConfig\ConfigBuilder; | 7 | use Graby\SiteConfig\ConfigBuilder; |
8 | use Psr\Log\LoggerInterface; | 8 | use Psr\Log\LoggerInterface; |
9 | use Wallabag\CoreBundle\Repository\SiteCredentialRepository; | ||
10 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | ||
9 | 11 | ||
10 | class GrabySiteConfigBuilder implements SiteConfigBuilder | 12 | class GrabySiteConfigBuilder implements SiteConfigBuilder |
11 | { | 13 | { |
@@ -13,27 +15,39 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder | |||
13 | * @var ConfigBuilder | 15 | * @var ConfigBuilder |
14 | */ | 16 | */ |
15 | private $grabyConfigBuilder; | 17 | private $grabyConfigBuilder; |
18 | |||
16 | /** | 19 | /** |
17 | * @var array | 20 | * @var SiteCredentialRepository |
18 | */ | 21 | */ |
19 | private $credentials; | 22 | private $credentialRepository; |
23 | |||
20 | /** | 24 | /** |
21 | * @var LoggerInterface | 25 | * @var LoggerInterface |
22 | */ | 26 | */ |
23 | private $logger; | 27 | private $logger; |
24 | 28 | ||
25 | /** | 29 | /** |
30 | * @var Wallabag\UserBundle\Entity\User|null | ||
31 | */ | ||
32 | private $currentUser; | ||
33 | |||
34 | /** | ||
26 | * GrabySiteConfigBuilder constructor. | 35 | * GrabySiteConfigBuilder constructor. |
27 | * | 36 | * |
28 | * @param ConfigBuilder $grabyConfigBuilder | 37 | * @param ConfigBuilder $grabyConfigBuilder |
29 | * @param array $credentials | 38 | * @param TokenStorage $token |
30 | * @param LoggerInterface $logger | 39 | * @param SiteCredentialRepository $credentialRepository |
40 | * @param LoggerInterface $logger | ||
31 | */ | 41 | */ |
32 | public function __construct(ConfigBuilder $grabyConfigBuilder, array $credentials, LoggerInterface $logger) | 42 | public function __construct(ConfigBuilder $grabyConfigBuilder, TokenStorage $token, SiteCredentialRepository $credentialRepository, LoggerInterface $logger) |
33 | { | 43 | { |
34 | $this->grabyConfigBuilder = $grabyConfigBuilder; | 44 | $this->grabyConfigBuilder = $grabyConfigBuilder; |
35 | $this->credentials = $credentials; | 45 | $this->credentialRepository = $credentialRepository; |
36 | $this->logger = $logger; | 46 | $this->logger = $logger; |
47 | |||
48 | if ($token->getToken()) { | ||
49 | $this->currentUser = $token->getToken()->getUser(); | ||
50 | } | ||
37 | } | 51 | } |
38 | 52 | ||
39 | /** | 53 | /** |
@@ -47,7 +61,12 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder | |||
47 | $host = substr($host, 4); | 61 | $host = substr($host, 4); |
48 | } | 62 | } |
49 | 63 | ||
50 | if (empty($this->credentials[$host])) { | 64 | $credentials = null; |
65 | if ($this->currentUser) { | ||
66 | $credentials = $this->credentialRepository->findOneByHostAndUser($host, $this->currentUser->getId()); | ||
67 | } | ||
68 | |||
69 | if (null === $credentials) { | ||
51 | $this->logger->debug('Auth: no credentials available for host.', ['host' => $host]); | 70 | $this->logger->debug('Auth: no credentials available for host.', ['host' => $host]); |
52 | 71 | ||
53 | return false; | 72 | return false; |
@@ -62,13 +81,14 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder | |||
62 | 'passwordField' => $config->login_password_field ?: null, | 81 | 'passwordField' => $config->login_password_field ?: null, |
63 | 'extraFields' => $this->processExtraFields($config->login_extra_fields), | 82 | 'extraFields' => $this->processExtraFields($config->login_extra_fields), |
64 | 'notLoggedInXpath' => $config->not_logged_in_xpath ?: null, | 83 | 'notLoggedInXpath' => $config->not_logged_in_xpath ?: null, |
65 | 'username' => $this->credentials[$host]['username'], | 84 | 'username' => $credentials['username'], |
66 | 'password' => $this->credentials[$host]['password'], | 85 | 'password' => $credentials['password'], |
67 | ]; | 86 | ]; |
68 | 87 | ||
69 | $config = new SiteConfig($parameters); | 88 | $config = new SiteConfig($parameters); |
70 | 89 | ||
71 | // do not leak password in log | 90 | // do not leak usernames and passwords in log |
91 | $parameters['username'] = '**masked**'; | ||
72 | $parameters['password'] = '**masked**'; | 92 | $parameters['password'] = '**masked**'; |
73 | 93 | ||
74 | $this->logger->debug('Auth: add parameters.', ['host' => $host, 'parameters' => $parameters]); | 94 | $this->logger->debug('Auth: add parameters.', ['host' => $host, 'parameters' => $parameters]); |
diff --git a/src/Wallabag/CoreBundle/Helper/CryptoProxy.php b/src/Wallabag/CoreBundle/Helper/CryptoProxy.php new file mode 100644 index 00000000..e8b19cb9 --- /dev/null +++ b/src/Wallabag/CoreBundle/Helper/CryptoProxy.php | |||
@@ -0,0 +1,86 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Helper; | ||
4 | |||
5 | use Psr\Log\LoggerInterface; | ||
6 | use Defuse\Crypto\Key; | ||
7 | use Defuse\Crypto\Crypto; | ||
8 | use Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException; | ||
9 | |||
10 | /** | ||
11 | * This is a proxy to crypt and decrypt password used by SiteCredential entity. | ||
12 | * BTW, It might be re-use for sth else. | ||
13 | */ | ||
14 | class CryptoProxy | ||
15 | { | ||
16 | private $logger; | ||
17 | private $encryptionKey; | ||
18 | |||
19 | public function __construct($encryptionKeyPath, LoggerInterface $logger) | ||
20 | { | ||
21 | $this->logger = $logger; | ||
22 | |||
23 | if (!file_exists($encryptionKeyPath)) { | ||
24 | $key = Key::createNewRandomKey(); | ||
25 | |||
26 | file_put_contents($encryptionKeyPath, $key->saveToAsciiSafeString()); | ||
27 | chmod($encryptionKeyPath, 0600); | ||
28 | } | ||
29 | |||
30 | $this->encryptionKey = file_get_contents($encryptionKeyPath); | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * Ensure the given value will be crypted. | ||
35 | * | ||
36 | * @param string $secretValue Secret valye to crypt | ||
37 | * | ||
38 | * @return string | ||
39 | */ | ||
40 | public function crypt($secretValue) | ||
41 | { | ||
42 | $this->logger->debug('Crypto: crypting value: '.$this->mask($secretValue)); | ||
43 | |||
44 | return Crypto::encrypt($secretValue, $this->loadKey()); | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * Ensure the given crypted value will be decrypted. | ||
49 | * | ||
50 | * @param string $cryptedValue The value to be decrypted | ||
51 | * | ||
52 | * @return string | ||
53 | */ | ||
54 | public function decrypt($cryptedValue) | ||
55 | { | ||
56 | $this->logger->debug('Crypto: decrypting value: '.$this->mask($cryptedValue)); | ||
57 | |||
58 | try { | ||
59 | return Crypto::decrypt($cryptedValue, $this->loadKey()); | ||
60 | } catch (WrongKeyOrModifiedCiphertextException $e) { | ||
61 | throw new \RuntimeException('Decrypt fail: '.$e->getMessage()); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * Load the private key. | ||
67 | * | ||
68 | * @return Key | ||
69 | */ | ||
70 | private function loadKey() | ||
71 | { | ||
72 | return Key::loadFromAsciiSafeString($this->encryptionKey); | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * Keep first and last character and put some stars in between. | ||
77 | * | ||
78 | * @param string $value Value to mask | ||
79 | * | ||
80 | * @return string | ||
81 | */ | ||
82 | private function mask($value) | ||
83 | { | ||
84 | return strlen($value) > 0 ? $value[0].'*****'.$value[strlen($value) - 1] : 'Empty value'; | ||
85 | } | ||
86 | } | ||
diff --git a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php new file mode 100644 index 00000000..36906761 --- /dev/null +++ b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php | |||
@@ -0,0 +1,47 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Repository; | ||
4 | |||
5 | use Wallabag\CoreBundle\Helper\CryptoProxy; | ||
6 | |||
7 | /** | ||
8 | * SiteCredentialRepository. | ||
9 | */ | ||
10 | class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository | ||
11 | { | ||
12 | private $cryptoProxy; | ||
13 | |||
14 | public function setCrypto(CryptoProxy $cryptoProxy) | ||
15 | { | ||
16 | $this->cryptoProxy = $cryptoProxy; | ||
17 | } | ||
18 | |||
19 | /** | ||
20 | * Retrieve one username/password for the given host and userId. | ||
21 | * | ||
22 | * @param string $host | ||
23 | * @param int $userId | ||
24 | * | ||
25 | * @return null|array | ||
26 | */ | ||
27 | public function findOneByHostAndUser($host, $userId) | ||
28 | { | ||
29 | $res = $this->createQueryBuilder('s') | ||
30 | ->select('s.username', 's.password') | ||
31 | ->where('s.host = :hostname')->setParameter('hostname', $host) | ||
32 | ->andWhere('s.user = :userId')->setParameter('userId', $userId) | ||
33 | ->setMaxResults(1) | ||
34 | ->getQuery() | ||
35 | ->getOneOrNullResult(); | ||
36 | |||
37 | if (null === $res) { | ||
38 | return; | ||
39 | } | ||
40 | |||
41 | // decrypt user & password before returning them | ||
42 | $res['username'] = $this->cryptoProxy->decrypt($res['username']); | ||
43 | $res['password'] = $this->cryptoProxy->decrypt($res['password']); | ||
44 | |||
45 | return $res; | ||
46 | } | ||
47 | } | ||
diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 4be79547..e09b0f18 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml | |||
@@ -63,7 +63,8 @@ services: | |||
63 | class: Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder | 63 | class: Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder |
64 | arguments: | 64 | arguments: |
65 | - "@wallabag_core.graby.config_builder" | 65 | - "@wallabag_core.graby.config_builder" |
66 | - "%sites_credentials%" | 66 | - "@security.token_storage" |
67 | - "@wallabag_core.site_credential_repository" | ||
67 | - '@logger' | 68 | - '@logger' |
68 | tags: | 69 | tags: |
69 | - { name: monolog.logger, channel: graby } | 70 | - { name: monolog.logger, channel: graby } |
@@ -120,6 +121,14 @@ services: | |||
120 | arguments: | 121 | arguments: |
121 | - WallabagCoreBundle:Tag | 122 | - WallabagCoreBundle:Tag |
122 | 123 | ||
124 | wallabag_core.site_credential_repository: | ||
125 | class: Wallabag\CoreBundle\Repository\SiteCredentialRepository | ||
126 | factory: [ "@doctrine.orm.default_entity_manager", getRepository ] | ||
127 | arguments: | ||
128 | - WallabagCoreBundle:SiteCredential | ||
129 | calls: | ||
130 | - [ setCrypto, [ "@wallabag_core.helper.crypto_proxy" ] ] | ||
131 | |||
123 | wallabag_core.helper.entries_export: | 132 | wallabag_core.helper.entries_export: |
124 | class: Wallabag\CoreBundle\Helper\EntriesExport | 133 | class: Wallabag\CoreBundle\Helper\EntriesExport |
125 | arguments: | 134 | arguments: |
@@ -201,3 +210,9 @@ services: | |||
201 | 210 | ||
202 | wallabag_core.entry.download_images.client: | 211 | wallabag_core.entry.download_images.client: |
203 | class: GuzzleHttp\Client | 212 | class: GuzzleHttp\Client |
213 | |||
214 | wallabag_core.helper.crypto_proxy: | ||
215 | class: Wallabag\CoreBundle\Helper\CryptoProxy | ||
216 | arguments: | ||
217 | - "%wallabag_core.site_credentials.encryption_key_path%" | ||
218 | - "@logger" | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 02dd04f2..a91a0ce4 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | # save_link: 'Save a link' | 32 | # save_link: 'Save a link' |
33 | back_to_unread: 'Tilbage til de ulæste artikler' | 33 | back_to_unread: 'Tilbage til de ulæste artikler' |
34 | # users_management: 'Users management' | 34 | # users_management: 'Users management' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Tilføj ny artikel' | 37 | add_new_entry: 'Tilføj ny artikel' |
37 | search: 'Søg' | 38 | search: 'Søg' |
@@ -520,6 +521,26 @@ user: | |||
520 | search: | 521 | search: |
521 | # placeholder: Filter by username or email | 522 | # placeholder: Filter by username or email |
522 | 523 | ||
524 | site_credential: | ||
525 | # page_title: Site credentials management | ||
526 | # new_site_credential: Create a credential | ||
527 | # edit_site_credential: Edit an existing credential | ||
528 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
529 | # list: | ||
530 | # actions: Actions | ||
531 | # edit_action: Edit | ||
532 | # yes: Yes | ||
533 | # no: No | ||
534 | # create_new_one: Create a new credential | ||
535 | # form: | ||
536 | # username_label: 'Username' | ||
537 | # host_label: 'Host' | ||
538 | # password_label: 'Password' | ||
539 | # save: Save | ||
540 | # delete: Delete | ||
541 | # delete_confirm: Are you sure? | ||
542 | # back_to_list: Back to list | ||
543 | |||
523 | error: | 544 | error: |
524 | # page_title: An error occurred | 545 | # page_title: An error occurred |
525 | 546 | ||
@@ -572,3 +593,8 @@ flashes: | |||
572 | # added: 'User "%username%" added' | 593 | # added: 'User "%username%" added' |
573 | # updated: 'User "%username%" updated' | 594 | # updated: 'User "%username%" updated' |
574 | # deleted: 'User "%username%" deleted' | 595 | # deleted: 'User "%username%" deleted' |
596 | site_credential: | ||
597 | notice: | ||
598 | # added: 'Site credential for "%host%" added' | ||
599 | # updated: 'Site credential for "%host%" updated' | ||
600 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index f6ccdae0..e77cdca3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | save_link: 'Link speichern' | 32 | save_link: 'Link speichern' |
33 | back_to_unread: 'Zurück zu ungelesenen Artikeln' | 33 | back_to_unread: 'Zurück zu ungelesenen Artikeln' |
34 | users_management: 'Benutzerverwaltung' | 34 | users_management: 'Benutzerverwaltung' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Neuen Artikel hinzufügen' | 37 | add_new_entry: 'Neuen Artikel hinzufügen' |
37 | search: 'Suche' | 38 | search: 'Suche' |
@@ -521,6 +522,26 @@ user: | |||
521 | search: | 522 | search: |
522 | placeholder: Filtere nach Benutzer oder E-Mail-Adresse | 523 | placeholder: Filtere nach Benutzer oder E-Mail-Adresse |
523 | 524 | ||
525 | site_credential: | ||
526 | # page_title: Site credentials management | ||
527 | # new_site_credential: Create a credential | ||
528 | # edit_site_credential: Edit an existing credential | ||
529 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
530 | list: | ||
531 | actions: Aktionen | ||
532 | edit_action: Bearbeiten | ||
533 | yes: Ja | ||
534 | no: Nein | ||
535 | # create_new_one: Create a new credential | ||
536 | form: | ||
537 | # username_label: 'Username' | ||
538 | # host_label: 'Host' | ||
539 | # password_label: 'Password' | ||
540 | save: Speichern | ||
541 | delete: Löschen | ||
542 | delete_confirm: Bist du sicher? | ||
543 | back_to_list: Zurück zur Liste | ||
544 | |||
524 | error: | 545 | error: |
525 | page_title: Ein Fehler ist aufgetreten | 546 | page_title: Ein Fehler ist aufgetreten |
526 | 547 | ||
@@ -573,3 +594,8 @@ flashes: | |||
573 | added: 'Benutzer "%username%" hinzugefügt' | 594 | added: 'Benutzer "%username%" hinzugefügt' |
574 | updated: 'Benutzer "%username%" aktualisiert' | 595 | updated: 'Benutzer "%username%" aktualisiert' |
575 | deleted: 'Benutzer "%username%" gelöscht' | 596 | deleted: 'Benutzer "%username%" gelöscht' |
597 | site_credential: | ||
598 | notice: | ||
599 | # added: 'Site credential for "%host%" added' | ||
600 | # updated: 'Site credential for "%host%" updated' | ||
601 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 902c3046..50edab3a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | save_link: 'Save a link' | 32 | save_link: 'Save a link' |
33 | back_to_unread: 'Back to unread articles' | 33 | back_to_unread: 'Back to unread articles' |
34 | users_management: 'Users management' | 34 | users_management: 'Users management' |
35 | site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Add a new entry' | 37 | add_new_entry: 'Add a new entry' |
37 | search: 'Search' | 38 | search: 'Search' |
@@ -521,6 +522,26 @@ user: | |||
521 | search: | 522 | search: |
522 | placeholder: Filter by username or email | 523 | placeholder: Filter by username or email |
523 | 524 | ||
525 | site_credential: | ||
526 | page_title: Site credentials management | ||
527 | new_site_credential: Create a credential | ||
528 | edit_site_credential: Edit an existing credential | ||
529 | description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
530 | list: | ||
531 | actions: Actions | ||
532 | edit_action: Edit | ||
533 | yes: Yes | ||
534 | no: No | ||
535 | create_new_one: Create a new credential | ||
536 | form: | ||
537 | username_label: 'Username' | ||
538 | host_label: 'Host' | ||
539 | password_label: 'Password' | ||
540 | save: Save | ||
541 | delete: Delete | ||
542 | delete_confirm: Are you sure? | ||
543 | back_to_list: Back to list | ||
544 | |||
524 | error: | 545 | error: |
525 | page_title: An error occurred | 546 | page_title: An error occurred |
526 | 547 | ||
@@ -573,3 +594,8 @@ flashes: | |||
573 | added: 'User "%username%" added' | 594 | added: 'User "%username%" added' |
574 | updated: 'User "%username%" updated' | 595 | updated: 'User "%username%" updated' |
575 | deleted: 'User "%username%" deleted' | 596 | deleted: 'User "%username%" deleted' |
597 | site_credential: | ||
598 | notice: | ||
599 | added: 'Site credential for "%host%" added' | ||
600 | updated: 'Site credential for "%host%" updated' | ||
601 | deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index afd6a7b1..6fbf00eb 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | save_link: 'Guardar un enlace' | 32 | save_link: 'Guardar un enlace' |
33 | back_to_unread: 'Volver a los artículos sin leer' | 33 | back_to_unread: 'Volver a los artículos sin leer' |
34 | users_management: 'Configuración de usuarios' | 34 | users_management: 'Configuración de usuarios' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Añadir un nuevo artículo' | 37 | add_new_entry: 'Añadir un nuevo artículo' |
37 | search: 'Buscar' | 38 | search: 'Buscar' |
@@ -521,6 +522,26 @@ user: | |||
521 | search: | 522 | search: |
522 | # placeholder: Filter by username or email | 523 | # placeholder: Filter by username or email |
523 | 524 | ||
525 | site_credential: | ||
526 | # page_title: Site credentials management | ||
527 | # new_site_credential: Create a credential | ||
528 | # edit_site_credential: Edit an existing credential | ||
529 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
530 | # list: | ||
531 | # actions: Actions | ||
532 | # edit_action: Edit | ||
533 | # yes: Yes | ||
534 | # no: No | ||
535 | # create_new_one: Create a new credential | ||
536 | # form: | ||
537 | # username_label: 'Username' | ||
538 | # host_label: 'Host' | ||
539 | # password_label: 'Password' | ||
540 | # save: Save | ||
541 | # delete: Delete | ||
542 | # delete_confirm: Are you sure? | ||
543 | # back_to_list: Back to list | ||
544 | |||
524 | error: | 545 | error: |
525 | page_title: Ha ocurrido un error | 546 | page_title: Ha ocurrido un error |
526 | 547 | ||
@@ -573,3 +594,8 @@ flashes: | |||
573 | added: 'Añadido el usuario "%username%"' | 594 | added: 'Añadido el usuario "%username%"' |
574 | updated: 'Actualizado el usuario "%username%"' | 595 | updated: 'Actualizado el usuario "%username%"' |
575 | deleted: 'Eliminado el usuario "%username%"' | 596 | deleted: 'Eliminado el usuario "%username%"' |
597 | site_credential: | ||
598 | notice: | ||
599 | # added: 'Site credential for "%host%" added' | ||
600 | # updated: 'Site credential for "%host%" updated' | ||
601 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 545514b3..ad7d6cd9 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | save_link: 'ذخیرهٔ یک پیوند' | 32 | save_link: 'ذخیرهٔ یک پیوند' |
33 | back_to_unread: 'بازگشت به خواندهنشدهها' | 33 | back_to_unread: 'بازگشت به خواندهنشدهها' |
34 | # users_management: 'Users management' | 34 | # users_management: 'Users management' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'افزودن مقالهٔ تازه' | 37 | add_new_entry: 'افزودن مقالهٔ تازه' |
37 | search: 'جستجو' | 38 | search: 'جستجو' |
@@ -521,6 +522,26 @@ user: | |||
521 | search: | 522 | search: |
522 | # placeholder: Filter by username or email | 523 | # placeholder: Filter by username or email |
523 | 524 | ||
525 | site_credential: | ||
526 | # page_title: Site credentials management | ||
527 | # new_site_credential: Create a credential | ||
528 | # edit_site_credential: Edit an existing credential | ||
529 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
530 | # list: | ||
531 | # actions: Actions | ||
532 | # edit_action: Edit | ||
533 | # yes: Yes | ||
534 | # no: No | ||
535 | # create_new_one: Create a new credential | ||
536 | # form: | ||
537 | # username_label: 'Username' | ||
538 | # host_label: 'Host' | ||
539 | # password_label: 'Password' | ||
540 | # save: Save | ||
541 | # delete: Delete | ||
542 | # delete_confirm: Are you sure? | ||
543 | # back_to_list: Back to list | ||
544 | |||
524 | error: | 545 | error: |
525 | # page_title: An error occurred | 546 | # page_title: An error occurred |
526 | 547 | ||
@@ -573,3 +594,8 @@ flashes: | |||
573 | # added: 'User "%username%" added' | 594 | # added: 'User "%username%" added' |
574 | # updated: 'User "%username%" updated' | 595 | # updated: 'User "%username%" updated' |
575 | # deleted: 'User "%username%" deleted' | 596 | # deleted: 'User "%username%" deleted' |
597 | site_credential: | ||
598 | notice: | ||
599 | # added: 'Site credential for "%host%" added' | ||
600 | # updated: 'Site credential for "%host%" updated' | ||
601 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index e9e79c67..c4b029c3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | save_link: "Sauvegarder un nouvel article" | 32 | save_link: "Sauvegarder un nouvel article" |
33 | back_to_unread: "Retour aux articles non lus" | 33 | back_to_unread: "Retour aux articles non lus" |
34 | users_management: "Gestion des utilisateurs" | 34 | users_management: "Gestion des utilisateurs" |
35 | site_credentials: 'Accès aux sites' | ||
35 | top: | 36 | top: |
36 | add_new_entry: "Sauvegarder un nouvel article" | 37 | add_new_entry: "Sauvegarder un nouvel article" |
37 | search: "Rechercher" | 38 | search: "Rechercher" |
@@ -516,11 +517,31 @@ user: | |||
516 | twofactor_label: "Double authentification" | 517 | twofactor_label: "Double authentification" |
517 | save: "Sauvegarder" | 518 | save: "Sauvegarder" |
518 | delete: "Supprimer" | 519 | delete: "Supprimer" |
519 | delete_confirm: "Voulez-vous vraiment ?" | 520 | delete_confirm: "Êtes-vous sûr ?" |
520 | back_to_list: "Revenir à la liste" | 521 | back_to_list: "Revenir à la liste" |
521 | search: | 522 | search: |
522 | placeholder: "Filtrer par nom d’utilisateur ou email" | 523 | placeholder: "Filtrer par nom d’utilisateur ou email" |
523 | 524 | ||
525 | site_credential: | ||
526 | page_title: Gestion des accès aux sites | ||
527 | new_site_credential: Créer un accès à un site | ||
528 | edit_site_credential: Éditer l'accès d'un site | ||
529 | description: "Ici vous pouvez gérer les accès aux différents sites. Ces accès permettent de récupérer des contenus sur des sites qui requièrent une authentification ou un paywall" | ||
530 | list: | ||
531 | actions: Actions | ||
532 | edit_action: Éditer | ||
533 | yes: Oui | ||
534 | no: Non | ||
535 | create_new_one: Créer un nouvel accès à un site | ||
536 | form: | ||
537 | username_label: 'Identifiant' | ||
538 | host_label: 'Domaine' | ||
539 | password_label: 'Mot de passe' | ||
540 | save: "Sauvegarder" | ||
541 | delete: "Supprimer" | ||
542 | delete_confirm: "Êtes-vous sûr ?" | ||
543 | back_to_list: "Revenir à la liste" | ||
544 | |||
524 | error: | 545 | error: |
525 | page_title: "Une erreur est survenue" | 546 | page_title: "Une erreur est survenue" |
526 | 547 | ||
@@ -570,6 +591,11 @@ flashes: | |||
570 | client_deleted: "Client %name% supprimé" | 591 | client_deleted: "Client %name% supprimé" |
571 | user: | 592 | user: |
572 | notice: | 593 | notice: |
573 | added: "Utilisateur \"%username%\" ajouté" | 594 | added: 'Utilisateur "%username%" ajouté' |
574 | updated: "Utilisateur \"%username%\" mis à jour" | 595 | updated: 'Utilisateur "%username%" mis à jour' |
575 | deleted: "Utilisateur \"%username%\" supprimé" | 596 | deleted: 'Utilisateur "%username%" supprimé' |
597 | site_credential: | ||
598 | notice: | ||
599 | added: 'Accès au site "%host%" ajouté' | ||
600 | updated: 'Accès au site "%host%" mis à jour' | ||
601 | deleted: 'Accès au site "%host%" supprimé' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 0597d3e3..4bd04aad 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | save_link: 'Salva collegamento' | 32 | save_link: 'Salva collegamento' |
33 | back_to_unread: 'Torna ai contenuti non letti' | 33 | back_to_unread: 'Torna ai contenuti non letti' |
34 | # users_management: 'Users management' | 34 | # users_management: 'Users management' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Aggiungi un nuovo contenuto' | 37 | add_new_entry: 'Aggiungi un nuovo contenuto' |
37 | search: 'Cerca' | 38 | search: 'Cerca' |
@@ -521,6 +522,26 @@ user: | |||
521 | search: | 522 | search: |
522 | # placeholder: Filter by username or email | 523 | # placeholder: Filter by username or email |
523 | 524 | ||
525 | site_credential: | ||
526 | # page_title: Site credentials management | ||
527 | # new_site_credential: Create a credential | ||
528 | # edit_site_credential: Edit an existing credential | ||
529 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
530 | # list: | ||
531 | # actions: Actions | ||
532 | # edit_action: Edit | ||
533 | # yes: Yes | ||
534 | # no: No | ||
535 | # create_new_one: Create a new credential | ||
536 | # form: | ||
537 | # username_label: 'Username' | ||
538 | # host_label: 'Host' | ||
539 | # password_label: 'Password' | ||
540 | # save: Save | ||
541 | # delete: Delete | ||
542 | # delete_confirm: Are you sure? | ||
543 | # back_to_list: Back to list | ||
544 | |||
524 | error: | 545 | error: |
525 | # page_title: An error occurred | 546 | # page_title: An error occurred |
526 | 547 | ||
@@ -573,3 +594,8 @@ flashes: | |||
573 | # added: 'User "%username%" added' | 594 | # added: 'User "%username%" added' |
574 | # updated: 'User "%username%" updated' | 595 | # updated: 'User "%username%" updated' |
575 | # deleted: 'User "%username%" deleted' | 596 | # deleted: 'User "%username%" deleted' |
597 | site_credential: | ||
598 | notice: | ||
599 | # added: 'Site credential for "%host%" added' | ||
600 | # updated: 'Site credential for "%host%" updated' | ||
601 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index c172a0f6..a6dd4dcd 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | save_link: 'Enregistrar un novèl article' | 32 | save_link: 'Enregistrar un novèl article' |
33 | back_to_unread: 'Tornar als articles pas legits' | 33 | back_to_unread: 'Tornar als articles pas legits' |
34 | users_management: 'Gestion dels utilizaires' | 34 | users_management: 'Gestion dels utilizaires' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Enregistrar un novèl article' | 37 | add_new_entry: 'Enregistrar un novèl article' |
37 | search: 'Cercar' | 38 | search: 'Cercar' |
@@ -521,6 +522,26 @@ user: | |||
521 | search: | 522 | search: |
522 | placeholder: "Filtrar per nom d'utilizaire o corrièl" | 523 | placeholder: "Filtrar per nom d'utilizaire o corrièl" |
523 | 524 | ||
525 | site_credential: | ||
526 | # page_title: Site credentials management | ||
527 | # new_site_credential: Create a credential | ||
528 | # edit_site_credential: Edit an existing credential | ||
529 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
530 | list: | ||
531 | actions: 'Accions' | ||
532 | edit_action: 'Modificar' | ||
533 | yes: 'Òc' | ||
534 | no: 'Non' | ||
535 | # create_new_one: Create a new credential | ||
536 | form: | ||
537 | # username_label: 'Username' | ||
538 | # host_label: 'Host' | ||
539 | # password_label: 'Password' | ||
540 | save: 'Enregistrar' | ||
541 | delete: 'Suprimir' | ||
542 | delete_confirm: 'Sètz segur ?' | ||
543 | back_to_list: 'Tornar a la lista' | ||
544 | |||
524 | error: | 545 | error: |
525 | page_title: Una error s'es produsida | 546 | page_title: Una error s'es produsida |
526 | 547 | ||
@@ -573,3 +594,8 @@ flashes: | |||
573 | added: 'Utilizaire "%username%" ajustat' | 594 | added: 'Utilizaire "%username%" ajustat' |
574 | updated: 'Utilizaire "%username%" mes a jorn' | 595 | updated: 'Utilizaire "%username%" mes a jorn' |
575 | deleted: 'Utilizaire "%username%" suprimit' | 596 | deleted: 'Utilizaire "%username%" suprimit' |
597 | site_credential: | ||
598 | notice: | ||
599 | # added: 'Site credential for "%host%" added' | ||
600 | # updated: 'Site credential for "%host%" updated' | ||
601 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 82d16767..7312abd7 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | save_link: 'Zapisz link' | 32 | save_link: 'Zapisz link' |
33 | back_to_unread: 'Powrót do nieprzeczytanych artykułów' | 33 | back_to_unread: 'Powrót do nieprzeczytanych artykułów' |
34 | users_management: 'Zarządzanie użytkownikami' | 34 | users_management: 'Zarządzanie użytkownikami' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Dodaj nowy wpis' | 37 | add_new_entry: 'Dodaj nowy wpis' |
37 | search: 'Szukaj' | 38 | search: 'Szukaj' |
@@ -521,6 +522,26 @@ user: | |||
521 | search: | 522 | search: |
522 | placeholder: Filtruj po nazwie użytkownika lub adresie e-mail | 523 | placeholder: Filtruj po nazwie użytkownika lub adresie e-mail |
523 | 524 | ||
525 | site_credential: | ||
526 | # page_title: Site credentials management | ||
527 | # new_site_credential: Create a credential | ||
528 | # edit_site_credential: Edit an existing credential | ||
529 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
530 | list: | ||
531 | actions: Akcje | ||
532 | edit_action: Edytuj | ||
533 | yes: Tak | ||
534 | no: Nie | ||
535 | # create_new_one: Create a new credential | ||
536 | form: | ||
537 | # username_label: 'Username' | ||
538 | # host_label: 'Host' | ||
539 | # password_label: 'Password' | ||
540 | save: Zapisz | ||
541 | delete: Usuń | ||
542 | delete_confirm: Jesteś pewien? | ||
543 | back_to_list: Powrót do listy | ||
544 | |||
524 | error: | 545 | error: |
525 | page_title: Wystąpił błąd | 546 | page_title: Wystąpił błąd |
526 | 547 | ||
@@ -573,3 +594,8 @@ flashes: | |||
573 | added: 'Użytkownik "%username%" dodany' | 594 | added: 'Użytkownik "%username%" dodany' |
574 | updated: 'Użytkownik "%username%" zaktualizowany' | 595 | updated: 'Użytkownik "%username%" zaktualizowany' |
575 | deleted: 'Użytkownik "%username%" usunięty' | 596 | deleted: 'Użytkownik "%username%" usunięty' |
597 | site_credential: | ||
598 | notice: | ||
599 | # added: 'Site credential for "%host%" added' | ||
600 | # updated: 'Site credential for "%host%" updated' | ||
601 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index b75567d6..18090352 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | save_link: 'Salvar um link' | 32 | save_link: 'Salvar um link' |
33 | back_to_unread: 'Voltar para os artigos não lidos' | 33 | back_to_unread: 'Voltar para os artigos não lidos' |
34 | users_management: 'Gestão de Usuários' | 34 | users_management: 'Gestão de Usuários' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Adicionar uma nova entrada' | 37 | add_new_entry: 'Adicionar uma nova entrada' |
37 | search: 'Pesquisa' | 38 | search: 'Pesquisa' |
@@ -521,6 +522,26 @@ user: | |||
521 | search: | 522 | search: |
522 | # placeholder: Filter by username or email | 523 | # placeholder: Filter by username or email |
523 | 524 | ||
525 | site_credential: | ||
526 | # page_title: Site credentials management | ||
527 | # new_site_credential: Create a credential | ||
528 | # edit_site_credential: Edit an existing credential | ||
529 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
530 | list: | ||
531 | actions: 'Ações' | ||
532 | edit_action: 'Editar' | ||
533 | yes: 'Sim' | ||
534 | no: 'Não' | ||
535 | # create_new_one: Create a new credential | ||
536 | form: | ||
537 | # username_label: 'Username' | ||
538 | # host_label: 'Host' | ||
539 | # password_label: 'Password' | ||
540 | save: 'Salvar' | ||
541 | delete: 'Apagar' | ||
542 | delete_confirm: 'Tem certeza?' | ||
543 | back_to_list: 'Voltar para a lista' | ||
544 | |||
524 | error: | 545 | error: |
525 | # page_title: An error occurred | 546 | # page_title: An error occurred |
526 | 547 | ||
@@ -573,3 +594,8 @@ flashes: | |||
573 | added: 'Usuário "%username%" adicionado' | 594 | added: 'Usuário "%username%" adicionado' |
574 | updated: 'Usuário "%username%" atualizado' | 595 | updated: 'Usuário "%username%" atualizado' |
575 | deleted: 'Usuário "%username%" removido' | 596 | deleted: 'Usuário "%username%" removido' |
597 | site_credential: | ||
598 | notice: | ||
599 | # added: 'Site credential for "%host%" added' | ||
600 | # updated: 'Site credential for "%host%" updated' | ||
601 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 95df573d..f8866fdc 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | # save_link: 'Save a link' | 32 | # save_link: 'Save a link' |
33 | back_to_unread: 'Înapoi la articolele necitite' | 33 | back_to_unread: 'Înapoi la articolele necitite' |
34 | # users_management: 'Users management' | 34 | # users_management: 'Users management' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Introdu un nou articol' | 37 | add_new_entry: 'Introdu un nou articol' |
37 | search: 'Căutare' | 38 | search: 'Căutare' |
@@ -521,6 +522,26 @@ user: | |||
521 | search: | 522 | search: |
522 | # placeholder: Filter by username or email | 523 | # placeholder: Filter by username or email |
523 | 524 | ||
525 | site_credential: | ||
526 | # page_title: Site credentials management | ||
527 | # new_site_credential: Create a credential | ||
528 | # edit_site_credential: Edit an existing credential | ||
529 | # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." | ||
530 | # list: | ||
531 | # actions: Actions | ||
532 | # edit_action: Edit | ||
533 | # yes: Yes | ||
534 | # no: No | ||
535 | # create_new_one: Create a new credential | ||
536 | # form: | ||
537 | # username_label: 'Username' | ||
538 | # host_label: 'Host' | ||
539 | # password_label: 'Password' | ||
540 | # save: Save | ||
541 | # delete: Delete | ||
542 | # delete_confirm: Are you sure? | ||
543 | # back_to_list: Back to list | ||
544 | |||
524 | error: | 545 | error: |
525 | # page_title: An error occurred | 546 | # page_title: An error occurred |
526 | 547 | ||
@@ -573,3 +594,8 @@ flashes: | |||
573 | # added: 'User "%username%" added' | 594 | # added: 'User "%username%" added' |
574 | # updated: 'User "%username%" updated' | 595 | # updated: 'User "%username%" updated' |
575 | # deleted: 'User "%username%" deleted' | 596 | # deleted: 'User "%username%" deleted' |
597 | site_credential: | ||
598 | notice: | ||
599 | # added: 'Site credential for "%host%" added' | ||
600 | # updated: 'Site credential for "%host%" updated' | ||
601 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 61e1a1ea..4d01e7f7 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml | |||
@@ -32,6 +32,7 @@ menu: | |||
32 | # save_link: 'Save a link' | 32 | # save_link: 'Save a link' |
33 | back_to_unread: 'Okunmayan makalelere geri dön' | 33 | back_to_unread: 'Okunmayan makalelere geri dön' |
34 | # users_management: 'Users management' | 34 | # users_management: 'Users management' |
35 | # site_credentials: 'Site credentials' | ||
35 | top: | 36 | top: |
36 | add_new_entry: 'Yeni bir makale ekle' | 37 | add_new_entry: 'Yeni bir makale ekle' |
37 | search: 'Ara' | 38 | search: 'Ara' |
@@ -571,3 +572,8 @@ flashes: | |||
571 | # added: 'User "%username%" added' | 572 | # added: 'User "%username%" added' |
572 | # updated: 'User "%username%" updated' | 573 | # updated: 'User "%username%" updated' |
573 | # deleted: 'User "%username%" deleted' | 574 | # deleted: 'User "%username%" deleted' |
575 | site_credential: | ||
576 | notice: | ||
577 | # added: 'Site credential for "%host%" added' | ||
578 | # updated: 'Site credential for "%host%" updated' | ||
579 | # deleted: 'Site credential for "%host%" deleted' | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/SiteCredential/edit.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/SiteCredential/edit.html.twig new file mode 100644 index 00000000..882be430 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/SiteCredential/edit.html.twig | |||
@@ -0,0 +1,60 @@ | |||
1 | {% extends "WallabagCoreBundle::layout.html.twig" %} | ||
2 | |||
3 | {% block title %}{{ 'site_credential.page_title'|trans }}{% endblock %} | ||
4 | |||
5 | {% block content %} | ||
6 | |||
7 | <div class="row"> | ||
8 | <div class="col s12"> | ||
9 | <div class="card-panel"> | ||
10 | <div class="row"> | ||
11 | <div class="input-field col s12"> | ||
12 | <h4>{{ 'site_credential.edit_site_credential'|trans }}</h4> | ||
13 | |||
14 | <div id="set6" class="col s12"> | ||
15 | {{ form_start(edit_form) }} | ||
16 | {{ form_errors(edit_form) }} | ||
17 | |||
18 | <div class="row"> | ||
19 | <div class="input-field col s12"> | ||
20 | {{ form_label(edit_form.host) }} | ||
21 | {{ form_errors(edit_form.host) }} | ||
22 | {{ form_widget(edit_form.host) }} | ||
23 | </div> | ||
24 | </div> | ||
25 | |||
26 | <div class="row"> | ||
27 | <div class="input-field col s12"> | ||
28 | {{ form_label(edit_form.username) }} | ||
29 | {{ form_errors(edit_form.username) }} | ||
30 | {{ form_widget(edit_form.username) }} | ||
31 | </div> | ||
32 | </div> | ||
33 | |||
34 | <div class="row"> | ||
35 | <div class="input-field col s12"> | ||
36 | {{ form_label(edit_form.password) }} | ||
37 | {{ form_errors(edit_form.password) }} | ||
38 | {{ form_widget(edit_form.password) }} | ||
39 | </div> | ||
40 | </div> | ||
41 | |||
42 | <br/> | ||
43 | |||
44 | {{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} | ||
45 | {{ form_widget(edit_form._token) }} | ||
46 | </form> | ||
47 | <p> | ||
48 | {{ form_start(delete_form) }} | ||
49 | <button onclick="return confirm('{{ 'site_credential.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'site_credential.form.delete'|trans }}</button> | ||
50 | {{ form_end(delete_form) }} | ||
51 | </p> | ||
52 | <p><a class="waves-effect waves-light btn blue-grey" href="{{ path('site_credentials_index') }}">{{ 'site_credential.form.back_to_list'|trans }}</a></p> | ||
53 | </div> | ||
54 | </div> | ||
55 | </div> | ||
56 | </div> | ||
57 | </div> | ||
58 | </div> | ||
59 | |||
60 | {% endblock %} | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/SiteCredential/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/SiteCredential/index.html.twig new file mode 100644 index 00000000..324854ad --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/SiteCredential/index.html.twig | |||
@@ -0,0 +1,42 @@ | |||
1 | {% extends "WallabagCoreBundle::layout.html.twig" %} | ||
2 | |||
3 | {% block title %}{{ 'site_credential.page_title'|trans }}{% endblock %} | ||
4 | |||
5 | {% block content %} | ||
6 | |||
7 | <div class="row"> | ||
8 | <div class="col s12"> | ||
9 | <div class="card-panel"> | ||
10 | <div class="row"> | ||
11 | <div class="input-field col s12"> | ||
12 | <p class="help">{{ 'site_credential.description'|trans|raw }}</p> | ||
13 | |||
14 | <table class="bordered"> | ||
15 | <thead> | ||
16 | <tr> | ||
17 | <th>{{ 'site_credential.form.host_label'|trans }}</th> | ||
18 | <th>{{ 'site_credential.list.actions'|trans }}</th> | ||
19 | </tr> | ||
20 | </thead> | ||
21 | <tbody> | ||
22 | {% for credential in credentials %} | ||
23 | <tr> | ||
24 | <td>{{ credential.host }}</td> | ||
25 | <td> | ||
26 | <a href="{{ path('site_credentials_edit', { 'id': credential.id }) }}">{{ 'site_credential.list.edit_action'|trans }}</a> | ||
27 | </td> | ||
28 | </tr> | ||
29 | {% endfor %} | ||
30 | </tbody> | ||
31 | </table> | ||
32 | <br /> | ||
33 | <p> | ||
34 | <a href="{{ path('site_credentials_new') }}" class="waves-effect waves-light btn">{{ 'site_credential.list.create_new_one'|trans }}</a> | ||
35 | </p> | ||
36 | </div> | ||
37 | </div> | ||
38 | </div> | ||
39 | </div> | ||
40 | </div> | ||
41 | |||
42 | {% endblock %} | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/SiteCredential/new.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/SiteCredential/new.html.twig new file mode 100644 index 00000000..3c008cde --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/SiteCredential/new.html.twig | |||
@@ -0,0 +1,53 @@ | |||
1 | {% extends "WallabagCoreBundle::layout.html.twig" %} | ||
2 | |||
3 | {% block title %}{{ 'site_credential.page_title'|trans }}{% endblock %} | ||
4 | |||
5 | {% block content %} | ||
6 | |||
7 | <div class="row"> | ||
8 | <div class="col s12"> | ||
9 | <div class="card-panel"> | ||
10 | <div class="row"> | ||
11 | <div class="input-field col s12"> | ||
12 | <h4>{{ 'site_credential.new_site_credential'|trans }}</h4> | ||
13 | |||
14 | <div id="set6" class="col s12"> | ||
15 | {{ form_start(form) }} | ||
16 | {{ form_errors(form) }} | ||
17 | |||
18 | <div class="row"> | ||
19 | <div class="input-field col s12"> | ||
20 | {{ form_label(form.host) }} | ||
21 | {{ form_errors(form.host) }} | ||
22 | {{ form_widget(form.host) }} | ||
23 | </div> | ||
24 | </div> | ||
25 | |||
26 | <div class="row"> | ||
27 | <div class="input-field col s12"> | ||
28 | {{ form_label(form.username) }} | ||
29 | {{ form_errors(form.username) }} | ||
30 | {{ form_widget(form.username) }} | ||
31 | </div> | ||
32 | </div> | ||
33 | |||
34 | <div class="row"> | ||
35 | <div class="input-field col s12"> | ||
36 | {{ form_label(form.password) }} | ||
37 | {{ form_errors(form.password) }} | ||
38 | {{ form_widget(form.password) }} | ||
39 | </div> | ||
40 | </div> | ||
41 | |||
42 | {{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} | ||
43 | {{ form_rest(form) }} | ||
44 | </form> | ||
45 | <p><a class="waves-effect waves-light btn blue-grey" href="{{ path('site_credentials_index') }}">{{ 'site_credential.form.back_to_list'|trans }}</a></p> | ||
46 | </div> | ||
47 | </div> | ||
48 | </div> | ||
49 | </div> | ||
50 | </div> | ||
51 | </div> | ||
52 | |||
53 | {% endblock %} | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig index 42aeace9..17fa13bb 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig | |||
@@ -38,6 +38,9 @@ | |||
38 | {{ render(controller("WallabagCoreBundle:Entry:searchForm", {'currentRoute': app.request.attributes.get('_route')})) }} | 38 | {{ render(controller("WallabagCoreBundle:Entry:searchForm", {'currentRoute': app.request.attributes.get('_route')})) }} |
39 | </div> | 39 | </div> |
40 | </li> | 40 | </li> |
41 | {% if craue_setting('restricted_access') %} | ||
42 | <li class="menu site_credentials"><a href="{{ path('site_credentials_index') }}">{{ 'menu.left.site_credentials'|trans }}</a></li> | ||
43 | {% endif %} | ||
41 | <li class="menu config"><a href="{{ path('config') }}">{{ 'menu.left.config'|trans }}</a></li> | 44 | <li class="menu config"><a href="{{ path('config') }}">{{ 'menu.left.config'|trans }}</a></li> |
42 | {% if is_granted('ROLE_SUPER_ADMIN') %} | 45 | {% if is_granted('ROLE_SUPER_ADMIN') %} |
43 | <li class="menu users"><a href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a></li> | 46 | <li class="menu users"><a href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a></li> |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index 9b0816eb..1e10bf38 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig | |||
@@ -66,13 +66,13 @@ | |||
66 | </div> | 66 | </div> |
67 | </div> | 67 | </div> |
68 | 68 | ||
69 | <div class="row"> | 69 | <div class="row"> |
70 | <div class="input-field col s12"> | 70 | <div class="input-field col s12"> |
71 | {{ form_errors(form.config.action_mark_as_read) }} | 71 | {{ form_label(form.config.action_mark_as_read) }} |
72 | {{ form_widget(form.config.action_mark_as_read) }} | 72 | {{ form_errors(form.config.action_mark_as_read) }} |
73 | {{ form_label(form.config.action_mark_as_read) }} | 73 | {{ form_widget(form.config.action_mark_as_read) }} |
74 | </div> | ||
74 | </div> | 75 | </div> |
75 | </div> | ||
76 | 76 | ||
77 | <div class="row"> | 77 | <div class="row"> |
78 | <div class="input-field col s11"> | 78 | <div class="input-field col s11"> |
@@ -254,11 +254,11 @@ | |||
254 | {{ form_start(form.pwd) }} | 254 | {{ form_start(form.pwd) }} |
255 | {{ form_errors(form.pwd) }} | 255 | {{ form_errors(form.pwd) }} |
256 | 256 | ||
257 | <div class="row"> | 257 | <div class="row"> |
258 | <div class="input-field col s12"> | 258 | <div class="input-field col s12"> |
259 | {{ 'config.form_password.description'|trans }} | 259 | {{ 'config.form_password.description'|trans }} |
260 | </div> | ||
260 | </div> | 261 | </div> |
261 | </div> | ||
262 | 262 | ||
263 | <div class="row"> | 263 | <div class="row"> |
264 | <div class="input-field col s12"> | 264 | <div class="input-field col s12"> |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/SiteCredential/edit.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/SiteCredential/edit.html.twig new file mode 100644 index 00000000..882be430 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/SiteCredential/edit.html.twig | |||
@@ -0,0 +1,60 @@ | |||
1 | {% extends "WallabagCoreBundle::layout.html.twig" %} | ||
2 | |||
3 | {% block title %}{{ 'site_credential.page_title'|trans }}{% endblock %} | ||
4 | |||
5 | {% block content %} | ||
6 | |||
7 | <div class="row"> | ||
8 | <div class="col s12"> | ||
9 | <div class="card-panel"> | ||
10 | <div class="row"> | ||
11 | <div class="input-field col s12"> | ||
12 | <h4>{{ 'site_credential.edit_site_credential'|trans }}</h4> | ||
13 | |||
14 | <div id="set6" class="col s12"> | ||
15 | {{ form_start(edit_form) }} | ||
16 | {{ form_errors(edit_form) }} | ||
17 | |||
18 | <div class="row"> | ||
19 | <div class="input-field col s12"> | ||
20 | {{ form_label(edit_form.host) }} | ||
21 | {{ form_errors(edit_form.host) }} | ||
22 | {{ form_widget(edit_form.host) }} | ||
23 | </div> | ||
24 | </div> | ||
25 | |||
26 | <div class="row"> | ||
27 | <div class="input-field col s12"> | ||
28 | {{ form_label(edit_form.username) }} | ||
29 | {{ form_errors(edit_form.username) }} | ||
30 | {{ form_widget(edit_form.username) }} | ||
31 | </div> | ||
32 | </div> | ||
33 | |||
34 | <div class="row"> | ||
35 | <div class="input-field col s12"> | ||
36 | {{ form_label(edit_form.password) }} | ||
37 | {{ form_errors(edit_form.password) }} | ||
38 | {{ form_widget(edit_form.password) }} | ||
39 | </div> | ||
40 | </div> | ||
41 | |||
42 | <br/> | ||
43 | |||
44 | {{ form_widget(edit_form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} | ||
45 | {{ form_widget(edit_form._token) }} | ||
46 | </form> | ||
47 | <p> | ||
48 | {{ form_start(delete_form) }} | ||
49 | <button onclick="return confirm('{{ 'site_credential.form.delete_confirm'|trans|escape('js') }}')" type="submit" class="btn waves-effect waves-light red">{{ 'site_credential.form.delete'|trans }}</button> | ||
50 | {{ form_end(delete_form) }} | ||
51 | </p> | ||
52 | <p><a class="waves-effect waves-light btn blue-grey" href="{{ path('site_credentials_index') }}">{{ 'site_credential.form.back_to_list'|trans }}</a></p> | ||
53 | </div> | ||
54 | </div> | ||
55 | </div> | ||
56 | </div> | ||
57 | </div> | ||
58 | </div> | ||
59 | |||
60 | {% endblock %} | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/SiteCredential/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/SiteCredential/index.html.twig new file mode 100644 index 00000000..324854ad --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/SiteCredential/index.html.twig | |||
@@ -0,0 +1,42 @@ | |||
1 | {% extends "WallabagCoreBundle::layout.html.twig" %} | ||
2 | |||
3 | {% block title %}{{ 'site_credential.page_title'|trans }}{% endblock %} | ||
4 | |||
5 | {% block content %} | ||
6 | |||
7 | <div class="row"> | ||
8 | <div class="col s12"> | ||
9 | <div class="card-panel"> | ||
10 | <div class="row"> | ||
11 | <div class="input-field col s12"> | ||
12 | <p class="help">{{ 'site_credential.description'|trans|raw }}</p> | ||
13 | |||
14 | <table class="bordered"> | ||
15 | <thead> | ||
16 | <tr> | ||
17 | <th>{{ 'site_credential.form.host_label'|trans }}</th> | ||
18 | <th>{{ 'site_credential.list.actions'|trans }}</th> | ||
19 | </tr> | ||
20 | </thead> | ||
21 | <tbody> | ||
22 | {% for credential in credentials %} | ||
23 | <tr> | ||
24 | <td>{{ credential.host }}</td> | ||
25 | <td> | ||
26 | <a href="{{ path('site_credentials_edit', { 'id': credential.id }) }}">{{ 'site_credential.list.edit_action'|trans }}</a> | ||
27 | </td> | ||
28 | </tr> | ||
29 | {% endfor %} | ||
30 | </tbody> | ||
31 | </table> | ||
32 | <br /> | ||
33 | <p> | ||
34 | <a href="{{ path('site_credentials_new') }}" class="waves-effect waves-light btn">{{ 'site_credential.list.create_new_one'|trans }}</a> | ||
35 | </p> | ||
36 | </div> | ||
37 | </div> | ||
38 | </div> | ||
39 | </div> | ||
40 | </div> | ||
41 | |||
42 | {% endblock %} | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/SiteCredential/new.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/SiteCredential/new.html.twig new file mode 100644 index 00000000..3c008cde --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/SiteCredential/new.html.twig | |||
@@ -0,0 +1,53 @@ | |||
1 | {% extends "WallabagCoreBundle::layout.html.twig" %} | ||
2 | |||
3 | {% block title %}{{ 'site_credential.page_title'|trans }}{% endblock %} | ||
4 | |||
5 | {% block content %} | ||
6 | |||
7 | <div class="row"> | ||
8 | <div class="col s12"> | ||
9 | <div class="card-panel"> | ||
10 | <div class="row"> | ||
11 | <div class="input-field col s12"> | ||
12 | <h4>{{ 'site_credential.new_site_credential'|trans }}</h4> | ||
13 | |||
14 | <div id="set6" class="col s12"> | ||
15 | {{ form_start(form) }} | ||
16 | {{ form_errors(form) }} | ||
17 | |||
18 | <div class="row"> | ||
19 | <div class="input-field col s12"> | ||
20 | {{ form_label(form.host) }} | ||
21 | {{ form_errors(form.host) }} | ||
22 | {{ form_widget(form.host) }} | ||
23 | </div> | ||
24 | </div> | ||
25 | |||
26 | <div class="row"> | ||
27 | <div class="input-field col s12"> | ||
28 | {{ form_label(form.username) }} | ||
29 | {{ form_errors(form.username) }} | ||
30 | {{ form_widget(form.username) }} | ||
31 | </div> | ||
32 | </div> | ||
33 | |||
34 | <div class="row"> | ||
35 | <div class="input-field col s12"> | ||
36 | {{ form_label(form.password) }} | ||
37 | {{ form_errors(form.password) }} | ||
38 | {{ form_widget(form.password) }} | ||
39 | </div> | ||
40 | </div> | ||
41 | |||
42 | {{ form_widget(form.save, {'attr': {'class': 'btn waves-effect waves-light'}}) }} | ||
43 | {{ form_rest(form) }} | ||
44 | </form> | ||
45 | <p><a class="waves-effect waves-light btn blue-grey" href="{{ path('site_credentials_index') }}">{{ 'site_credential.form.back_to_list'|trans }}</a></p> | ||
46 | </div> | ||
47 | </div> | ||
48 | </div> | ||
49 | </div> | ||
50 | </div> | ||
51 | </div> | ||
52 | |||
53 | {% endblock %} | ||
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig index 2dab1c18..60907e11 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig | |||
@@ -66,6 +66,11 @@ | |||
66 | <li class="bold {% if currentRoute == 'config' %}active{% endif %}"> | 66 | <li class="bold {% if currentRoute == 'config' %}active{% endif %}"> |
67 | <a class="waves-effect" href="{{ path('config') }}">{{ 'menu.left.config'|trans }}</a> | 67 | <a class="waves-effect" href="{{ path('config') }}">{{ 'menu.left.config'|trans }}</a> |
68 | </li> | 68 | </li> |
69 | {% if craue_setting('restricted_access') %} | ||
70 | <li class="bold {% if currentRoute starts with 'site_credentials_' %}active{% endif %}"> | ||
71 | <a class="waves-effect" href="{{ path('site_credentials_index') }}">{{ 'menu.left.site_credentials'|trans }}</a> | ||
72 | </li> | ||
73 | {% endif %} | ||
69 | {% if is_granted('ROLE_SUPER_ADMIN') %} | 74 | {% if is_granted('ROLE_SUPER_ADMIN') %} |
70 | <li class="bold {% if currentRoute starts with 'user_' %}active{% endif %}"> | 75 | <li class="bold {% if currentRoute starts with 'user_' %}active{% endif %}"> |
71 | <a class="waves-effect" href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a> | 76 | <a class="waves-effect" href="{{ path('user_index') }}">{{ 'menu.left.users_management'|trans }}</a> |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 853f37f2..7cf28bfe 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -5,6 +5,7 @@ namespace Tests\Wallabag\CoreBundle\Controller; | |||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
6 | use Wallabag\CoreBundle\Entity\Config; | 6 | use Wallabag\CoreBundle\Entity\Config; |
7 | use Wallabag\CoreBundle\Entity\Entry; | 7 | use Wallabag\CoreBundle\Entity\Entry; |
8 | use Wallabag\CoreBundle\Entity\SiteCredential; | ||
8 | 9 | ||
9 | class EntryControllerTest extends WallabagCoreTestCase | 10 | class EntryControllerTest extends WallabagCoreTestCase |
10 | { | 11 | { |
@@ -1335,4 +1336,56 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1335 | $this->assertEquals($url, $content->getUrl()); | 1336 | $this->assertEquals($url, $content->getUrl()); |
1336 | $this->assertEquals($expectedLanguage, $content->getLanguage()); | 1337 | $this->assertEquals($expectedLanguage, $content->getLanguage()); |
1337 | } | 1338 | } |
1339 | |||
1340 | /** | ||
1341 | * This test will require an internet connection. | ||
1342 | */ | ||
1343 | public function testRestrictedArticle() | ||
1344 | { | ||
1345 | $url = 'http://www.monde-diplomatique.fr/2017/05/BONNET/57475'; | ||
1346 | $this->logInAs('admin'); | ||
1347 | $client = $this->getClient(); | ||
1348 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
1349 | |||
1350 | // enable restricted access | ||
1351 | $client->getContainer()->get('craue_config')->set('restricted_access', 1); | ||
1352 | |||
1353 | // create a new site_credential | ||
1354 | $user = $client->getContainer()->get('security.token_storage')->getToken()->getUser(); | ||
1355 | $credential = new SiteCredential($user); | ||
1356 | $credential->setHost('monde-diplomatique.fr'); | ||
1357 | $credential->setUsername($client->getContainer()->get('wallabag_core.helper.crypto_proxy')->crypt('foo')); | ||
1358 | $credential->setPassword($client->getContainer()->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); | ||
1359 | |||
1360 | $em->persist($credential); | ||
1361 | $em->flush(); | ||
1362 | |||
1363 | $crawler = $client->request('GET', '/new'); | ||
1364 | |||
1365 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
1366 | |||
1367 | $form = $crawler->filter('form[name=entry]')->form(); | ||
1368 | |||
1369 | $data = [ | ||
1370 | 'entry[url]' => $url, | ||
1371 | ]; | ||
1372 | |||
1373 | $client->submit($form, $data); | ||
1374 | |||
1375 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
1376 | |||
1377 | $crawler = $client->followRedirect(); | ||
1378 | |||
1379 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
1380 | $this->assertContains('flashes.entry.notice.entry_saved', $crawler->filter('body')->extract(['_text'])[0]); | ||
1381 | |||
1382 | $content = $em | ||
1383 | ->getRepository('WallabagCoreBundle:Entry') | ||
1384 | ->findByUrlAndUserId($url, $this->getLoggedInUserId()); | ||
1385 | |||
1386 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | ||
1387 | $this->assertSame('Crimes et réformes aux Philippines', $content->getTitle()); | ||
1388 | |||
1389 | $client->getContainer()->get('craue_config')->set('restricted_access', 0); | ||
1390 | } | ||
1338 | } | 1391 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php new file mode 100644 index 00000000..e73a9743 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php | |||
@@ -0,0 +1,139 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\CoreBundle\Controller; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Client; | ||
6 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
7 | use Wallabag\CoreBundle\Entity\SiteCredential; | ||
8 | |||
9 | class SiteCredentialControllerTest extends WallabagCoreTestCase | ||
10 | { | ||
11 | public function testListSiteCredential() | ||
12 | { | ||
13 | $this->logInAs('admin'); | ||
14 | $client = $this->getClient(); | ||
15 | |||
16 | $crawler = $client->request('GET', '/site-credentials/'); | ||
17 | |||
18 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
19 | |||
20 | $body = $crawler->filter('body')->extract(['_text'])[0]; | ||
21 | |||
22 | $this->assertContains('site_credential.description', $body); | ||
23 | $this->assertContains('site_credential.list.create_new_one', $body); | ||
24 | } | ||
25 | |||
26 | public function testNewSiteCredential() | ||
27 | { | ||
28 | $this->logInAs('admin'); | ||
29 | $client = $this->getClient(); | ||
30 | |||
31 | $crawler = $client->request('GET', '/site-credentials/new'); | ||
32 | |||
33 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
34 | |||
35 | $body = $crawler->filter('body')->extract(['_text'])[0]; | ||
36 | |||
37 | $this->assertContains('site_credential.new_site_credential', $body); | ||
38 | $this->assertContains('site_credential.form.back_to_list', $body); | ||
39 | |||
40 | $form = $crawler->filter('button[id=site_credential_save]')->form(); | ||
41 | |||
42 | $data = [ | ||
43 | 'site_credential[host]' => 'google.io', | ||
44 | 'site_credential[username]' => 'sergei', | ||
45 | 'site_credential[password]' => 'microsoft', | ||
46 | ]; | ||
47 | |||
48 | $client->submit($form, $data); | ||
49 | |||
50 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
51 | |||
52 | $crawler = $client->followRedirect(); | ||
53 | |||
54 | $this->assertContains('flashes.site_credential.notice.added', $crawler->filter('body')->extract(['_text'])[0]); | ||
55 | } | ||
56 | |||
57 | public function testEditSiteCredential() | ||
58 | { | ||
59 | $this->logInAs('admin'); | ||
60 | $client = $this->getClient(); | ||
61 | |||
62 | $credential = $this->createSiteCredential($client); | ||
63 | |||
64 | $crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit'); | ||
65 | |||
66 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
67 | |||
68 | $body = $crawler->filter('body')->extract(['_text'])[0]; | ||
69 | |||
70 | $this->assertContains('site_credential.edit_site_credential', $body); | ||
71 | $this->assertContains('site_credential.form.back_to_list', $body); | ||
72 | |||
73 | $form = $crawler->filter('button[id=site_credential_save]')->form(); | ||
74 | |||
75 | $data = [ | ||
76 | 'site_credential[host]' => 'google.io', | ||
77 | 'site_credential[username]' => 'larry', | ||
78 | 'site_credential[password]' => 'microsoft', | ||
79 | ]; | ||
80 | |||
81 | $client->submit($form, $data); | ||
82 | |||
83 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
84 | |||
85 | $crawler = $client->followRedirect(); | ||
86 | |||
87 | $this->assertContains('flashes.site_credential.notice.updated', $crawler->filter('body')->extract(['_text'])[0]); | ||
88 | } | ||
89 | |||
90 | public function testEditFromADifferentUserSiteCredential() | ||
91 | { | ||
92 | $this->logInAs('admin'); | ||
93 | $client = $this->getClient(); | ||
94 | |||
95 | $credential = $this->createSiteCredential($client); | ||
96 | |||
97 | $this->logInAs('bob'); | ||
98 | |||
99 | $client->request('GET', '/site-credentials/'.$credential->getId().'/edit'); | ||
100 | |||
101 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); | ||
102 | } | ||
103 | |||
104 | public function testDeleteSiteCredential() | ||
105 | { | ||
106 | $this->logInAs('admin'); | ||
107 | $client = $this->getClient(); | ||
108 | |||
109 | $credential = $this->createSiteCredential($client); | ||
110 | |||
111 | $crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit'); | ||
112 | |||
113 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
114 | |||
115 | $deleteForm = $crawler->filter('body')->selectButton('site_credential.form.delete')->form(); | ||
116 | |||
117 | $client->submit($deleteForm, []); | ||
118 | |||
119 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
120 | |||
121 | $crawler = $client->followRedirect(); | ||
122 | |||
123 | $this->assertContains('flashes.site_credential.notice.deleted', $crawler->filter('body')->extract(['_text'])[0]); | ||
124 | } | ||
125 | |||
126 | private function createSiteCredential(Client $client) | ||
127 | { | ||
128 | $credential = new SiteCredential($this->getLoggedInUser()); | ||
129 | $credential->setHost('google.io'); | ||
130 | $credential->setUsername('sergei'); | ||
131 | $credential->setPassword('microsoft'); | ||
132 | |||
133 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
134 | $em->persist($credential); | ||
135 | $em->flush(); | ||
136 | |||
137 | return $credential; | ||
138 | } | ||
139 | } | ||
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php index 8b50bce9..b0c81e7b 100644 --- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php +++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php | |||
@@ -6,10 +6,11 @@ use Monolog\Handler\TestHandler; | |||
6 | use Monolog\Logger; | 6 | use Monolog\Logger; |
7 | use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; | 7 | use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; |
8 | use Graby\SiteConfig\SiteConfig as GrabySiteConfig; | 8 | use Graby\SiteConfig\SiteConfig as GrabySiteConfig; |
9 | use PHPUnit_Framework_TestCase; | ||
10 | use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder; | 9 | use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder; |
10 | use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; | ||
11 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | ||
11 | 12 | ||
12 | class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase | 13 | class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase |
13 | { | 14 | { |
14 | /** @var \Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder */ | 15 | /** @var \Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder */ |
15 | protected $builder; | 16 | protected $builder; |
@@ -17,13 +18,13 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase | |||
17 | public function testBuildConfigExists() | 18 | public function testBuildConfigExists() |
18 | { | 19 | { |
19 | /* @var \Graby\SiteConfig\ConfigBuilder|\PHPUnit_Framework_MockObject_MockObject */ | 20 | /* @var \Graby\SiteConfig\ConfigBuilder|\PHPUnit_Framework_MockObject_MockObject */ |
20 | $grabyConfigBuilderMock = $this->getMockBuilder('\Graby\SiteConfig\ConfigBuilder') | 21 | $grabyConfigBuilderMock = $this->getMockBuilder('Graby\SiteConfig\ConfigBuilder') |
21 | ->disableOriginalConstructor() | 22 | ->disableOriginalConstructor() |
22 | ->getMock(); | 23 | ->getMock(); |
23 | 24 | ||
24 | $grabySiteConfig = new GrabySiteConfig(); | 25 | $grabySiteConfig = new GrabySiteConfig(); |
25 | $grabySiteConfig->requires_login = true; | 26 | $grabySiteConfig->requires_login = true; |
26 | $grabySiteConfig->login_uri = 'http://example.com/login'; | 27 | $grabySiteConfig->login_uri = 'http://www.example.com/login'; |
27 | $grabySiteConfig->login_username_field = 'login'; | 28 | $grabySiteConfig->login_username_field = 'login'; |
28 | $grabySiteConfig->login_password_field = 'password'; | 29 | $grabySiteConfig->login_password_field = 'password'; |
29 | $grabySiteConfig->login_extra_fields = ['field=value']; | 30 | $grabySiteConfig->login_extra_fields = ['field=value']; |
@@ -38,19 +39,40 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase | |||
38 | $handler = new TestHandler(); | 39 | $handler = new TestHandler(); |
39 | $logger->pushHandler($handler); | 40 | $logger->pushHandler($handler); |
40 | 41 | ||
42 | $siteCrentialRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\SiteCredentialRepository') | ||
43 | ->disableOriginalConstructor() | ||
44 | ->getMock(); | ||
45 | $siteCrentialRepo->expects($this->once()) | ||
46 | ->method('findOneByHostAndUser') | ||
47 | ->with('example.com', 1) | ||
48 | ->willReturn(['username' => 'foo', 'password' => 'bar']); | ||
49 | |||
50 | $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User') | ||
51 | ->disableOriginalConstructor() | ||
52 | ->getMock(); | ||
53 | $user->expects($this->once()) | ||
54 | ->method('getId') | ||
55 | ->willReturn(1); | ||
56 | |||
57 | $token = new UsernamePasswordToken($user, 'pass', 'provider'); | ||
58 | |||
59 | $tokenStorage = new TokenStorage(); | ||
60 | $tokenStorage->setToken($token); | ||
61 | |||
41 | $this->builder = new GrabySiteConfigBuilder( | 62 | $this->builder = new GrabySiteConfigBuilder( |
42 | $grabyConfigBuilderMock, | 63 | $grabyConfigBuilderMock, |
43 | ['example.com' => ['username' => 'foo', 'password' => 'bar']], | 64 | $tokenStorage, |
65 | $siteCrentialRepo, | ||
44 | $logger | 66 | $logger |
45 | ); | 67 | ); |
46 | 68 | ||
47 | $config = $this->builder->buildForHost('example.com'); | 69 | $config = $this->builder->buildForHost('www.example.com'); |
48 | 70 | ||
49 | $this->assertEquals( | 71 | $this->assertEquals( |
50 | new SiteConfig([ | 72 | new SiteConfig([ |
51 | 'host' => 'example.com', | 73 | 'host' => 'example.com', |
52 | 'requiresLogin' => true, | 74 | 'requiresLogin' => true, |
53 | 'loginUri' => 'http://example.com/login', | 75 | 'loginUri' => 'http://www.example.com/login', |
54 | 'usernameField' => 'login', | 76 | 'usernameField' => 'login', |
55 | 'passwordField' => 'password', | 77 | 'passwordField' => 'password', |
56 | 'extraFields' => ['field' => 'value'], | 78 | 'extraFields' => ['field' => 'value'], |
@@ -82,9 +104,30 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase | |||
82 | $handler = new TestHandler(); | 104 | $handler = new TestHandler(); |
83 | $logger->pushHandler($handler); | 105 | $logger->pushHandler($handler); |
84 | 106 | ||
107 | $siteCrentialRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\SiteCredentialRepository') | ||
108 | ->disableOriginalConstructor() | ||
109 | ->getMock(); | ||
110 | $siteCrentialRepo->expects($this->once()) | ||
111 | ->method('findOneByHostAndUser') | ||
112 | ->with('unknown.com', 1) | ||
113 | ->willReturn(null); | ||
114 | |||
115 | $user = $this->getMockBuilder('Wallabag\UserBundle\Entity\User') | ||
116 | ->disableOriginalConstructor() | ||
117 | ->getMock(); | ||
118 | $user->expects($this->once()) | ||
119 | ->method('getId') | ||
120 | ->willReturn(1); | ||
121 | |||
122 | $token = new UsernamePasswordToken($user, 'pass', 'provider'); | ||
123 | |||
124 | $tokenStorage = new TokenStorage(); | ||
125 | $tokenStorage->setToken($token); | ||
126 | |||
85 | $this->builder = new GrabySiteConfigBuilder( | 127 | $this->builder = new GrabySiteConfigBuilder( |
86 | $grabyConfigBuilderMock, | 128 | $grabyConfigBuilderMock, |
87 | [], | 129 | $tokenStorage, |
130 | $siteCrentialRepo, | ||
88 | $logger | 131 | $logger |
89 | ); | 132 | ); |
90 | 133 | ||
diff --git a/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php b/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php new file mode 100644 index 00000000..cede8696 --- /dev/null +++ b/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php | |||
@@ -0,0 +1,40 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\CoreBundle\Helper; | ||
4 | |||
5 | use Psr\Log\NullLogger; | ||
6 | use Monolog\Logger; | ||
7 | use Monolog\Handler\TestHandler; | ||
8 | use Wallabag\CoreBundle\Helper\CryptoProxy; | ||
9 | |||
10 | class CryptoProxyTest extends \PHPUnit_Framework_TestCase | ||
11 | { | ||
12 | public function testCrypto() | ||
13 | { | ||
14 | $logHandler = new TestHandler(); | ||
15 | $logger = new Logger('test', [$logHandler]); | ||
16 | |||
17 | $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', $logger); | ||
18 | $crypted = $crypto->crypt('test'); | ||
19 | $decrypted = $crypto->decrypt($crypted); | ||
20 | |||
21 | $this->assertSame('test', $decrypted); | ||
22 | |||
23 | $records = $logHandler->getRecords(); | ||
24 | $this->assertCount(2, $records); | ||
25 | $this->assertContains('Crypto: crypting value', $records[0]['message']); | ||
26 | $this->assertContains('Crypto: decrypting value', $records[1]['message']); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * @expectedException RuntimeException | ||
31 | * @expectedExceptionMessage Decrypt fail | ||
32 | * | ||
33 | * @return [type] [description] | ||
34 | */ | ||
35 | public function testDecryptBadValue() | ||
36 | { | ||
37 | $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', new NullLogger()); | ||
38 | $crypto->decrypt('badvalue'); | ||
39 | } | ||
40 | } | ||