diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index fc9d411..fc54db1 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -15,4 +15,9 @@
test/
+
+
+ src
+
+
diff --git a/src/Authentication/ClientJwtAuthenticator.php b/src/Authentication/ClientJwtAuthenticator.php
new file mode 100644
index 0000000..653e70b
--- /dev/null
+++ b/src/Authentication/ClientJwtAuthenticator.php
@@ -0,0 +1,63 @@
+jwt = $jwt;
+ $this->authId = $authid;
+ }
+
+ /**
+ * Get AuthID
+ *
+ * @return mixed
+ */
+ public function getAuthId()
+ {
+ return $this->authId;
+ }
+
+ /**
+ * Set AuthID
+ *
+ * @param mixed $authid
+ */
+ public function setAuthId($authid)
+ {
+ $this->authId = $authid;
+ }
+
+ /**
+ * Get list supported authentication method
+ *
+ * @return array
+ */
+ public function getAuthMethods()
+ {
+ return ['jwt'];
+ }
+
+ /**
+ * Get authentication message from challenge message
+ *
+ * @param ChallengeMessage $msg
+ * @return AuthenticateMessage
+ */
+ public function getAuthenticateFromChallenge(ChallengeMessage $msg)
+ {
+ return new AuthenticateMessage($this->jwt);
+ }
+}
\ No newline at end of file
diff --git a/test/Peer/ClientTest.php b/test/Peer/ClientTest.php
index d96de98..cdf1703 100644
--- a/test/Peer/ClientTest.php
+++ b/test/Peer/ClientTest.php
@@ -3,6 +3,8 @@
namespace Thruway\Peer;
use React\EventLoop\Factory;
+use Thruway\Authentication\ClientJwtAuthenticator;
+use Thruway\Authentication\ClientWampCraAuthenticator;
use Thruway\Transport\ClientTestTransportProvider;
class ClientTest extends \PHPUnit_Framework_TestCase
@@ -26,4 +28,23 @@ public function testClientSendsHelloMessage()
$client->addTransportProvider(new ClientTestTransportProvider());
}
+
+ public function testAddAuthenticators()
+ {
+ $client = new Client('some.realm', Factory::create());
+
+ $this->assertEmpty($client->getAuthMethods());
+
+ $client->addClientAuthenticator(new ClientJwtAuthenticator('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdXRoaWQiOiJhZG1pbiIsImF1dGhyb2xlcyI6WyJhZG1pbiJdfQ.rgRR61pbyg-qimH1zdh_naLwHz3UOoYRaJA0JPuutC4',
+ 'someId'));
+
+ $this->assertContains('jwt', $client->getAuthMethods());
+ $this->assertNotContains('wampcra', $client->getAuthMethods());
+
+ $client->addClientAuthenticator(new ClientWampCraAuthenticator('someId'));
+
+ $this->assertContains('jwt', $client->getAuthMethods());
+ $this->assertContains('wampcra', $client->getAuthMethods());
+ }
+
}
\ No newline at end of file