Commit 8618f390 authored by Mat's avatar Mat
parent c3d1601f
......@@ -16,6 +16,7 @@
!/var/SymfonyRequirements.php
/vendor/
/web/bundles/
/config/jwt/
## ?? GIT or NOT GIT ??
bin/
......
......@@ -23,6 +23,7 @@ class AppKernel extends Kernel
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
new FOS\UserBundle\FOSUserBundle(),
new SocketBundle\SocketBundle(),
new Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
......
......@@ -89,3 +89,10 @@ fos_user:
from_email:
address: mat@collectifs.net
sender_name: admin
# JWT token authentification
lexik_jwt_authentication:
secret_key: '%kernel.project_dir%/config/jwt/private.pem' # required for token creation
public_key: '%kernel.project_dir%/config/jwt/public.pem' # required for token verification
pass_phrase: '1234' # required for token creation, usage of an environment variable is recommended
token_ttl: 3600
\ No newline at end of file
......@@ -57,5 +57,14 @@ class WsCommand extends ContainerAwareCommand
$server->run();
}
/*
*
* NOTES TOKEN JWT
* -> https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/index.md#installation
* -> suis la procédure de création de clé
*
*/
}
\ No newline at end of file
......@@ -66,6 +66,10 @@ class ChatController extends Controller
*/
public function messageAction()
{
$tokenManager = $this->get('lexik_jwt_authentication.jwt_manager');
$token = $tokenManager->create($this->getUser());
dump($token);
return $this->render('@Socket/Chat/message.html.twig', array(
'token' => $token
));
......
......@@ -61,6 +61,9 @@ class ChatHub implements MessageComponentInterface
'timestamp' => (new \DateTime())->getTimestamp()
]);
// le prof montre d'abord ceci :
//$this->container->get("security.token_storage")->getToken()->getUser();
$conn->send($response);
}
......@@ -109,6 +112,9 @@ class ChatHub implements MessageComponentInterface
function onMessage(ConnectionInterface $from, $msg)
{
echo "Le message '". $msg ."' a été reçu\n";
$tokenManager = $this->container->get('lexik_jwt_authentication.jwt_manager');
foreach ($this->clients as $client)
{
$response = json_encode([
......
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