使用 amazon simpledb 匿名读取
我想使用 javascript 直接从客户端查询 simpledb。我的应用程序读取量很大,我不想通过我的应用程序服务器路由请求。是否可以在没有身份验证的情况下执行选择请求?
我可以设置一个身份验证服务器,但这相当不雅,因为它只会对每个读取请求说“是”,并且会引入另一个瓶颈/减速/故障点。
其他云数据库解决方案(微软、谷歌)是否有此功能?
I would like to query simpledb directly from the client using javascript. My application is read-heavy and I rather not route the request through my application server. Is it possible to perform a select request without authentication?
I could set up an authentication server, but this is rather inelegant as it will just be saying yes to every read request and would introduce another bottleneck/speedbump/point of failure.
Do the other cloud db solutions (microsoft, google) have this functionality?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可以使用 AWS IAM (身份和访问管理) 和服务器端“令牌自动售货机"。 AWS 文档有一篇专门针对用例使用令牌自动售货机对 AWS 移动应用程序的用户进行身份验证 和 GitHub 中的服务器、iOS 和 Android 示例代码。通用技术可用于非移动和/或 JavaScript 客户端。
注意:仍然需要服务器组件来分发临时访问令牌。但是,这些请求的数量可以显着减少(最多每 36 小时一次)。其余的请求都是从不受信任的客户端直接发送到 SimpleDB,没有中间人。
一般技术
只读访问策略
“只读访问策略”
这超出了简单数据库。您可以为其他几个 AWS 资源设置访问策略(请参阅完全访问策略示例)。
用静态资源替换动态客户端-服务器调用的变体
虽然您无法消除服务器组件,但客户端不一定必须直接与自动售货机对话:
令牌
,其中N + fudge == token expiry
token
写入公共 S3 存储桶(或任何其他静态资源)fudge
设置适当的maxAge缓存控制标头token
token
进行身份验证,使读取仅调用 SimpleDBThis is possible using AWS IAM (Identity and Access Management) and a server side "token vending machine". AWS docs have an article specifically written for the use case Authenticating Users of AWS Mobile Applications with a Token Vending Machine and sample code for server, iOS, and Android in GitHub. The general technique can be used for non-mobile and/or for JavaScript clients.
Note: a server component is still required to vend out the temporary access tokens. However, the volume of these requests can be significantly reduced (up to once every 36 hours). The remaining requests are from untrusted client to SimpleDB directly, no intermediary.
General Technique
Read Only Access Policy
From AWS sample code "Read Only Access Policy"
This extends beyond SimpleDB. You can set an access policy for several other AWS resources (see full access policy example).
Variation to Replace Dynamic Client-Server calls with Static Resource
Although you cannot eliminate a server component, clients don't necessarily have to talk to the vending machine directly:
token
every N seconds whereN + fudge == token expiry
token
to public S3 bucket (or any other static resource)fudge
token
from static URItoken
, makes read-only calls to SimpleDB您需要使用服务器签署所有请求。无论如何,我想这就是你的意思。您仍然可以节省一些带宽。
我想说,一旦 JavaScript 客户端能够验证自身身份,每个人都可以。
You would need to sign all requests with your server. I think that's what you mean anyway. You could still save some bandwidth.
I'd say, as soon as a JavaScript client can authenticate itself, everyone could.
需要身份验证服务器,您可以使用 EC2 来实现此目的。
An authentication server is required, you can use EC2 for this.