--- /dev/null
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration;
+use Doctrine\DBAL\Schema\Schema;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Add the restricted_access internal setting for articles with paywall
+ */
+class Version20161122144743 extends AbstractMigration implements ContainerAwareInterface
+{
+ /**
+ * @var ContainerInterface
+ */
+ private $container;
+
+ public function setContainer(ContainerInterface $container = null)
+ {
+ $this->container = $container;
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function up(Schema $schema)
+ {
+ $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')");
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function down(Schema $schema)
+ {
+ $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';");
+ }
+}
demo_mode_username: "Demo user"
share_public: Allow public url for entries
download_images_enabled: Download images locally
+restricted_access: Enable authentication for websites with paywall
'value' => '0',
'section' => 'misc',
],
+ [
+ 'name' => 'restricted_access',
+ 'value' => '0',
+ 'section' => 'entry',
+ ],
];
foreach ($settings as $setting) {
'value' => '0',
'section' => 'misc',
],
+ [
+ 'name' => 'restricted_access',
+ 'value' => '0',
+ 'section' => 'entry',
+ ],
];
foreach ($settings as $setting) {
/** @var \GuzzleHttp\Cookie\CookieJar */
private $cookieJar;
+ private $restrictedAccess;
+
/**
* HttpClientFactory constructor.
*
* @param \GuzzleHttp\Event\SubscriberInterface $authenticatorSubscriber
* @param \GuzzleHttp\Cookie\CookieJar $cookieJar
+ * @param string $restrictedAccess
*/
- public function __construct(SubscriberInterface $authenticatorSubscriber, CookieJar $cookieJar)
+ public function __construct(SubscriberInterface $authenticatorSubscriber, CookieJar $cookieJar, $restrictedAccess)
{
$this->authenticatorSubscriber = $authenticatorSubscriber;
$this->cookieJar = $cookieJar;
+ $this->restrictedAccess = $restrictedAccess;
}
/**
- * @return \GuzzleHttp\Client
+ * @return \GuzzleHttp\Client|null
*/
public function buildHttpClient()
{
+ if (0 === (int) $this->restrictedAccess) {
+ return null;
+ }
+
// we clear the cookie to avoid websites who use cookies for analytics
$this->cookieJar->clear();
// need to set the (shared) cookie jar
arguments:
- "@bd_guzzle_site_authenticator.authenticator_subscriber"
- "@wallabag_core.guzzle.cookie_jar"
+ - '@=service(''craue_config'').get(''restricted_access'')'
wallabag_core.guzzle.cookie_jar:
class: GuzzleHttp\Cookie\FileCookieJar