From 7aab0ecf2f78ce58f28b53c1fa19bfd824cc3cd7 Mon Sep 17 00:00:00 2001 From: Bertrand Dunogier Date: Thu, 29 Sep 2016 10:14:43 +0200 Subject: Added authentication for restricted access articles Fix #438. Thank you so much @bdunogier --- .../CoreBundle/Helper/HttpClientFactory.php | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Helper/HttpClientFactory.php (limited to 'src/Wallabag/CoreBundle/Helper/HttpClientFactory.php') diff --git a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php new file mode 100644 index 00000000..3e1d1ed5 --- /dev/null +++ b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php @@ -0,0 +1,44 @@ +authenticatorSubscriber = $authenticatorSubscriber; + $this->cookieJar = $cookieJar; + } + + /** + * @return \GuzzleHttp\Client + */ + public function buildHttpClient() + { + // need to set the (shared) cookie jar + $client = new Client(['handler' => new SafeCurlHandler(), 'defaults' => ['cookies' => $this->cookieJar]]); + $client->getEmitter()->attach($this->authenticatorSubscriber); + + return $client; + } +} -- cgit v1.2.3 From 40f3ea57fbc86247495ef3c335f40f966a69aa50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 22 Nov 2016 14:25:51 +0100 Subject: Cleared CookieJar to avoid websites who use cookies for analytics --- src/Wallabag/CoreBundle/Helper/HttpClientFactory.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Wallabag/CoreBundle/Helper/HttpClientFactory.php') diff --git a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php index 3e1d1ed5..161a5e9f 100644 --- a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php +++ b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php @@ -35,6 +35,8 @@ class HttpClientFactory */ public function buildHttpClient() { + // we clear the cookie to avoid websites who use cookies for analytics + $this->cookieJar->clear(); // need to set the (shared) cookie jar $client = new Client(['handler' => new SafeCurlHandler(), 'defaults' => ['cookies' => $this->cookieJar]]); $client->getEmitter()->attach($this->authenticatorSubscriber); -- cgit v1.2.3 From d64bf7953b0e4e793d7f75ec50bf6e42652560b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 22 Nov 2016 14:56:53 +0100 Subject: Added internal setting to enable/disable articles with paywall --- src/Wallabag/CoreBundle/Helper/HttpClientFactory.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Helper/HttpClientFactory.php') diff --git a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php index 161a5e9f..ca84c8da 100644 --- a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php +++ b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php @@ -18,23 +18,31 @@ class HttpClientFactory /** @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 -- cgit v1.2.3 From d51093a7d964ca720793d0cfcf4af601f2de448a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 22 Nov 2016 15:58:00 +0100 Subject: Added documentation and missing translations --- src/Wallabag/CoreBundle/Helper/HttpClientFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Helper/HttpClientFactory.php') diff --git a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php index ca84c8da..8891887b 100644 --- a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php +++ b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php @@ -25,7 +25,7 @@ class HttpClientFactory * * @param \GuzzleHttp\Event\SubscriberInterface $authenticatorSubscriber * @param \GuzzleHttp\Cookie\CookieJar $cookieJar - * @param string $restrictedAccess + * @param string $restrictedAccess this param is a kind of boolean. Values: 0 or 1 */ public function __construct(SubscriberInterface $authenticatorSubscriber, CookieJar $cookieJar, $restrictedAccess) { -- cgit v1.2.3