如何用thrift处理认证和授权?
我正在开发一个使用节俭的系统。我希望检查客户身份并对操作进行 ACL。 Thrift 是否为这些提供任何支持?
I'm developing a system which uses thrift. I'd like clients identity to be checked and operations to be ACLed. Does Thrift provide any support for those?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不直接。执行此操作的唯一方法是使用一种身份验证方法,该方法在服务器上创建一个(临时)密钥,然后更改所有方法,以便第一个参数是该密钥,并且它们都会另外引发未经身份验证的错误。例如:
我们使用此方法并将密钥保存到安全的 memcached 实例,密钥超时时间为 30 分钟,以保持一切“快速”。收到 AuthTimeoutException 的客户端应重新授权并重试,我们有一些防火墙规则来阻止暴力攻击。
Not directly. The only way to do this is to have an authentication method which creates a (temporary) key on the server, and then change all your methods so that the first argument is this key and they all additionally raise an not-authenticated error. For instance:
We use this method and save our keys to a secured memcached instance with a 30min timeout for keys to keep everything "snappy". Clients who receive an
AuthTimeoutException
are expected to reauthorise and retry and we have some firewall rules to stop brute-force attacks.像自动授权和权限这样的任务不被视为 Thrift 的一部分,主要是因为这些东西(通常)与应用程序逻辑比与一般的 RPC/序列化概念更相关。 Thrift 目前唯一支持的就是
TSASLTransport
。我自己不能对这个说太多,只是因为我从来没有觉得有必要使用它。另一种选择可能是使用
THeaderTransport
不幸的是,在撰写本文时仅使用 C++ 实现。因此,如果您打算将其与其他语言一起使用,您可能需要投入一些额外的工作。不用说,我们接受捐款......Tasks like autorisation and permissions are not considered as a part of Thrift, mostly because these things are (usually) more related to the application logic than to a general RPC/serialization concept. The only Thing that Thrift supports out of the box right now is the
TSASLTransport
. I can't say much about that one myself, simply because I never felt the need to use it.The other option could be to make use of
THeaderTransport
which unfortunately at the time of writing is only implemented with C++. Hence, if you plan to use it with some other language you may have to invest some additional work. Needless to say that we accept contributions ...有点晚了(我猜很晚了),但几年前我已经为此修改了 Thrift 源代码。
刚刚向 https://issues.apache.org/jira/ 提交了带有补丁的票证浏览/THRIFT-4221就是为了这个。
看看那个。基本上,该提案是添加一个“BeforeAction”挂钩来完成此操作。
Golang 生成差异示例
A bit late (I guess very late) but I had modified the Thrift Source code for this a couple of years ago.
Just submitted a ticket with the Patch to https://issues.apache.org/jira/browse/THRIFT-4221 for just this.
Have a look at that. Basically the proposal is to add a "BeforeAction" hook that does exactly that.
Example Golang generated diff