1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-17 17:08:37 +00:00

Added authentication for restricted access articles

Fix #438. Thank you so much @bdunogier
This commit is contained in:
Bertrand Dunogier 2016-09-29 10:14:43 +02:00 committed by Nicolas Lœuillet
parent bb28368f69
commit 7aab0ecf2f
7 changed files with 235 additions and 1 deletions

View file

@ -0,0 +1,44 @@
<?php
namespace Wallabag\CoreBundle\Helper;
use Graby\Ring\Client\SafeCurlHandler;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Event\SubscriberInterface;
/**
* Builds and configures the Guzzle HTTP client.
*/
class HttpClientFactory
{
/** @var \GuzzleHttp\Event\SubscriberInterface */
private $authenticatorSubscriber;
/** @var \GuzzleHttp\Cookie\CookieJar */
private $cookieJar;
/**
* HttpClientFactory constructor.
*
* @param \GuzzleHttp\Event\SubscriberInterface $authenticatorSubscriber
* @param \GuzzleHttp\Cookie\CookieJar $cookieJar
*/
public function __construct(SubscriberInterface $authenticatorSubscriber, CookieJar $cookieJar)
{
$this->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;
}
}