我绕着圈子试图让这个工作......
情况如下:
我有一个 PHP Web 应用程序,它使用Thruway通过Crossbar.io路由器对多个微服务进行远程过程调用 (RPC) 。匿名呼叫运行良好,但现在我想添加身份验证。
这是横杆配置:
{
"controller": {
},
"workers": [
{
"type": "router",
"realms": [
{
"name": "dashboard",
"roles": [
{
"name": "microservice",
"permissions": [
{
"uri": "*",
"publish": true,
"subscribe": true,
"call": true,
"register": true
}
]
}
]
}
],
"transports": [
{
"type": "websocket",
"endpoint": {
"type": "tcp",
"port": 80
},
"auth": {
"wampcra": {
"type": "static",
"users": {
"client1": {
"secret": "secret1",
"role": "microservice"
}
}
}
}
}
]
}
]
}
Crossbar 服务器(我希望)仅设置为路由器。所有客户端/工作人员都在其他服务器上。我一直在关注Crossbar 配置的这个例子——特别是这个配置文件。示例和我的配置之间有几个重要的区别:示例服务器既配置为路由器,也提供静态网页(我的没有),示例服务器包含一个 Python 组件(如果我正在阅读它正确)对身份验证过程并不重要。
在我的开发环境中,我试图让身份验证为一个客户工作。这是客户端代码:
<?php
// include the autoloader
//
require __DIR__ . '/vendor/autoload.php';
use Thruway\ClientSession;
use Thruway\Peer\Client;
use Thruway\Transport\PawlTransportProvider;
use Thruway\Authentication\ClientWampCraAuthenticator;
// create the WAMP client
//
$client = new Client('dashboard');
$auth = new ClientWampCraAuthenticator("client1", "secret1");
$client->addClientAuthenticator($auth);
// add the WAMP transport provider
//
$client->addTransportProvider(
new PawlTransportProvider('ws://192.168.1.10/')
);
// handle the "open" (connect) event
//
$client->on('open', function (ClientSession $session) {
// register the getImageData procedure
//
$session->register('service.client1.get', function ($data) {
return (new Client)->get();
});
});
// start the client
//
$client->start();
问题是服务器永远不会发送“挑战”消息。当客户端尝试连接时,我收到以下调试消息:
2015-07-07T13:58:17.7451860 debug [Thruway\Transport\PawlTransportProvider 204] Received: [3,{"message":"no user with authid 'anonymous' in user database"},"wamp.error.not_authorized"]
谁能解释我需要做哪些额外的配置才能让服务器挑战客户端?