限制对 Azure blob 的 http 访问

Restrict http access to Azure blobs

我有一个 MVC 5 互联网应用程序,其中包含托管在 Azure 上的 Web api 2 Web 服务。在 MVC 应用程序中,用户可以将文件上传到 Azure blob 容器。目前,一旦创建了一个 blob,任何人都可以访问这个 blob 的 http 地址。

我还在编写一个 android 应用程序,它从 Web 服务检索图像 url,然后这些图像显示在 android 应用程序中。

我想将对这些图像的访问限制为只有 android 应用程序的用户。

我是否应该使用共享访问签名来限制对 blob 的 http 访问,以便只有我的 android 应用程序可以对 blob 进行 http 访问?这是否应该在 JSON 数据发送到 android 应用程序之前在 Web api 2 控制器中完成?

提前致谢。

Should I use Shared Access Signatures to restrict http access to the blobs so that only my android application has http access to the blobs?

是的。到今天为止,这将是限制对 blob 的访问的唯一方法。请确保包含这些 blob 的 blob 容器具有 Private ACL。此外,在创建共享访问签名 (SAS) 时,请确保 SAS 在短时间内有效,这样即使用户以某种方式共享 SAS URL,在一段时间后也无法访问 blob .

Should this be done in the web api 2 controller before the JSON data is sent to the android application?

在不知道您的应用程序详细信息的情况下,这有点难以回答,但通常应该采用这种方法。您的 WebAPI 控制器应该 return SAS URL 个 blob。