javascript - 使用 SAS token 从浏览器访问/更新 Azure Blob 存储是否安全?

标签 javascript azure blob

我正在尝试使用 SAS token 将文件从 Javascript 上传到 Azure blob 存储。 SAS token 有权创建/删除/更新 blob。通过赋予 SAS token 到期时间来共享具有所有这些权限的 SAS token 是否安全?

或者,我应该创建一个 API 来上传文件,并让 javascript 调用该 API(.NET 应用程序),从而将文件上传到 Blob 存储,而不是向用户公开 token 。这样,我就会遇到性能问题,因为我的文件大小最大可达 10MB。

最好的方法是什么?

最佳答案

Shared access signatures are useful for providing limited permissions to your storage account to clients that should not have the account key.

如果是将数据写入存储帐户的人,请在服务器端执行此操作。当然,您可以让前端从后端请求 SAS token 。 SAS token 可以使用近期到期时间。最后,您仍然向任何可以访问前端的人开放部分存储帐户。

With near-term expiration, even if a SAS is compromised, it's valid only for a short time. This practice is especially important if you cannot reference a stored access policy. Near-term expiration times also limit the amount of data that can be written to a blob by limiting the time available to upload to it

来源:Using shared access signatures (SAS)

如果您对上传文件的大小有疑问,请查看执行 chunked upload 。根据您正在构建的前端类型,有很多分块上传的解决方案,例如 ngx-uploadx对于 Angular 。

关于javascript - 使用 SAS token 从浏览器访问/更新 Azure Blob 存储是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54085298/

相关文章:

javascript - IE 8 安全警告 - 选择不显示不安全项目 - JS 仍然运行吗?

javascript - DataTables - 固定 header - 头部对齐问题中的多个 tr

c# - 如何在 Azure 应用程序设置中管理 Web.Config 的自定义部分?

Azure 表存储 - 每天的客户数据

java - 使用 Spark 从 Azure Blob 读取数据

azure - Blob 存储 403 未经授权

java - 使用 jaybird 2.1.6 在 blob 字段中插入文件

java - 读取 blob 格式

javascript - (gs.left != (t = left + "px") && (gs.left = t);) 是做什么的?

javascript - 对于 HTML5 视频页面的 mp4 视频,播放/暂停等视频控件未在 android chrome 上显示