Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

权限验证怎么做? #18

Closed
tim1020 opened this issue Jan 26, 2020 · 3 comments
Closed

权限验证怎么做? #18

tim1020 opened this issue Jan 26, 2020 · 3 comments

Comments

@tim1020
Copy link

tim1020 commented Jan 26, 2020

看例子随便一个client设置一下$registerAddress,就可以给所有客户端发消息了,那样就避免不了一些“非法”client“乱”发消息。

如果在其它客户端做消息签名校验之类好像又不太好,有没办法在服务端设置校验?只有校验通过的client消息才能发给其它客户端?

@walkor
Copy link
Owner

walkor commented Jan 26, 2020

GatewayClient 和 GatewayWorker是在一个内网里使用,start_gateway.php里$gateway->lanIp设置成内网ip,register服务监听内网ip即可。
例如GatewayClient 和 GatewayWorker在同一台服务器的话$gateway->lanIp设置127.0.0.1,start_register.php里0.0.0.0改成127.0.0.0.1。
这样外部网络就无法通过GatewayClient连接你的Gateway服务了。

@tim1020
Copy link
Author

tim1020 commented Jan 28, 2020

GatewayClient 和 GatewayWorker是在一个内网里使用,start_gateway.php里$gateway->lanIp设置成内网ip,register服务监听内网ip即可。
例如GatewayClient 和 GatewayWorker在同一台服务器的话$gateway->lanIp设置127.0.0.1,start_register.php里0.0.0.0改成127.0.0.0.1。
这样外部网络就无法通过GatewayClient连接你的Gateway服务了。

这个我知道,但问题是内网也是有不同的业务划分的,也不是在同一个内网就有权。

甚至更复杂的是,同一个gateway跑多个业务,不同的client只能给各自的业务发消息。

@walkor
Copy link
Owner

walkor commented Jan 29, 2020

Gateway和GatewayClient支持设置secretKey,secretKey类似密码的作用,用法是
start_gateway.php start_businessworker.php start_register.php 里分别加上

$gateway->secretKey='yourpassword';
$worker->secretKey='yourpassword';
$register->secretKey='yourpassword';

GatewayClient调用前设置secretKey类似如下

Gateway::$secretKey='yourpassword';

保证所有地方secretKey都设置一致,这样外部没有正确的secretKey时就无法调用了。

@walkor walkor closed this as completed Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants