使用 amazon simpledb 匿名读取

发布于 2024-10-17 04:08:21 字数 193 浏览 7 评论 0原文

我想使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你的他你的她 2024-10-24 04:08:21

这可以使用 AWS IAM (身份和访问管理) 和服务器端“令牌自动售货机"。 AWS 文档有一篇专门针对用例使用令牌自动售货机对 AWS 移动应用程序的用户进行身份验证 和 GitHub 中的服务器、iOS 和 Android 示例代码。通用技术可用于非移动和/或 JavaScript 客户端。

注意:仍然需要服务器组件来分发临时访问令牌。但是,这些请求的数量可以显着减少(最多每 36 小时一次)。其余的请求都是从不受信任的客户端直接发送到 SimpleDB,没有中间人。

一般技术

  1. 匿名客户端调用你的令牌自动售货机(你的服务器)
  2. 令牌自动售货机知道密钥,调用AWS生成临时令牌
  3. 自动售货机将令牌返回给客户端
  4. 客户端使用匿名临时令牌调用 simpleDB API;无法写入 AWS 示例代码中的 SimpleDB

只读访问策略

只读访问策略

{
  "Statement": [
    {
      "Action": ["sdb:GetAttributes", "sdb:List*", "sdb:Select*"],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}

这超出了简单数据库。您可以为其他几个 AWS 资源设置访问策略(请参阅完全访问策略示例)。

用静态资源替换动态客户端-服务器调用的变体

虽然您无法消除服务器组件,但客户端不一定必须直接与自动售货机对话:

  1. 计划作业每 N 秒生成 令牌,其中 N + fudge == token expiry
  2. 作业将 token 写入公共 S3 存储桶(或任何其他静态资源)
    • 根据fudge设置适当的maxAge缓存控制标头
  3. 匿名客户端从静态URI读取token
  4. 客户端使用token进行身份验证,使读取仅调用 SimpleDB

This 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

  1. anonymous client calls your token vending machine (your server)
  2. token vending machine knows the secret key, calls AWS to generate a temporary token
  3. vending machine returns token to client
  4. client calls simpleDB API using anonymous, temporary token; cannot write to SimpleDB

Read Only Access Policy

From AWS sample code "Read Only Access Policy"

{
  "Statement": [
    {
      "Action": ["sdb:GetAttributes", "sdb:List*", "sdb:Select*"],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}

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:

  1. scheduled job generates token every N seconds where N + fudge == token expiry
  2. job writes token to public S3 bucket (or any other static resource)
    • set appropriate maxAge cache-control header based on fudge
  3. anonymous client reads token from static URI
  4. client authenticates with token, makes read-only calls to SimpleDB
一指流沙 2024-10-24 04:08:21

您需要使用服务器签署所有请求。无论如何,我想这就是你的意思。您仍然可以节省一些带宽。

我想说,一旦 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.

莫多说 2024-10-24 04:08:21

需要身份验证服务器,您可以使用 EC2 来实现此目的。

An authentication server is required, you can use EC2 for this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文