Commit 23747c2c authored by Avris's avatar Avris

fix cookie issue

parent c29af63c
......@@ -17,6 +17,7 @@ security:
encryptCookies: true
secureHeaders:
enabled: true
autoCookie: true
social:
sources: [facebook, google, github]
......
......@@ -5,13 +5,13 @@ use App\Model\Authenticator;
use App\Model\User;
use App\Event\UpdateProjectEvent;
use App\Event\UpdateServerEvent;
use Avris\Bag\NotFoundException;
use Avris\Micrus\Controller\Http\HeaderBag;
use Avris\Micrus\Notify\Notify;
use Avris\Micrus\Tool\Security\Crypt;
use Avris\Micrus\Tool\Security\SecurityManager;
use Doctrine\ORM\EntityManager;
use Hoa\Socket\Client;
use Hoa\Socket\Exception\Exception as SocketException;
use Hoa\Websocket\Client as WebClient;
class SocketClient
......@@ -40,12 +40,11 @@ class SocketClient
User $user = null,
$secret = null
) {
$this->client = new WebClient(new Client($host . '/' . urlencode($this->buildToken($crypt, $user, $secret))));
$this->client->setHost($headers->has('host') ? (string) $headers->get('host') : 'localhost');
try {
$this->client = new WebClient(new Client($host . '/' . urlencode($this->buildToken($crypt, $user, $secret))));
$this->client->setHost($headers->has('host') ? (string) $headers->get('host') : 'localhost');
$this->client->connect();
} catch (SocketException $e) {
} catch (\Exception $e) {
$notify->handle($e);
}
......@@ -61,6 +60,10 @@ class SocketClient
/** @var Authenticator $auth */
$auth = $user->getAuthenticators(SecurityManager::AUTHENTICATOR_COOKIE)->first();
if (!$auth) {
throw new NotFoundException();
}
return $crypt->encrypt($user->getIdentifier() . '|' . $auth->getPayload());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment