简体   繁体   English

Azure blob存储:多个容器的共享访问签名?

[英]Azure blob storage: Shared access signature for multiple containers?

I'm creating an application that will be hosted in Azure. 我正在创建一个将在Azure中托管的应用程序。 In this application, users will be able to upload their own content. 在此应用程序中,用户将能够上传自己的内容。 They will also be able to configure a list of other trusted app users who will be able to read their files. 他们还将能够配置能够读取其文件的其他受信任应用用户的列表。 I'm trying to figure out how to architect the storage. 我正在试图弄清楚如何构建存储。

I think that I'll create a storage container named after each user's application ID, and they will be able to upload files there. 我认为我将创建一个以每个用户的应用程序ID命名的存储容器,并且他们将能够在那里上传文件。 My question relates to how to grant read access to all files to which a user should have access. 我的问题涉及如何授予用户应该访问的所有文件的读访问权限。 I've been reading about shared access signatures and they seem like they could be a great fit for what I'm trying to achieve. 我一直在阅读有关共享访问签名的内容,他们似乎非常适合我正在努力实现的目标。 But, I'm evaluating the most efficient way to grant access to users. 但是,我正在评估授予用户访问权限的最有效方式。 I think that Stored access policies might be useful. 我认为存储访问策略可能很有用。 But specifically: 但具体来说:

Can I use one shared access signature (or stored access policy) to grant a user access to multiple containers? 我可以使用一个共享访问签名(或存储的访问策略)来授予用户访问多个容器的权限吗? I've found one piece of information which I think is very relevant: 我发现了一条我认为非常相关的信息:

http://msdn.microsoft.com/en-us/library/windowsazure/ee393341.aspx

"A container, queue, or table can include up to 5 stored access policies. Each policy can be used by any number of shared access signatures." “容器,队列或表最多可包含5个存储的访问策略。每个策略都可以由任意数量的共享访问签名使用。”

But I'm not sure if I'm understanding that correctly. 但我不确定我是否理解正确。 If a user is connected to 20 other people, can I grant him or her access to twenty specific containers? 如果用户与其他20个人连接,我可以授予他或她访问20个特定容器的权限吗? Of course, I could generate twenty individual stored access policies, but that doesn't seem very efficient, and when they first log in, I plan to show a summary of content from all of their other trusted app users, which would equate to demanding 20 signatures at once (if I understand correctly). 当然,我可以生成20个单独的存储访问策略,但这看起来效率不高,当他们第一次登录时,我计划显示来自所有其他可信应用用户的内容摘要,这相当于要求一次20个签名(如果我理解正确的话)。

Thanks for any suggestions... -Ben 谢谢你的任何建议...... - 贝恩

Since you are going to have a container per user (for now I'll equate a user with what you called a user application ID), that means you'll have a storage account that can contain many different containers for many users. 由于您将为每个用户创建一个容器(现在我将用户与您所谓的用户应用程序ID等同),这意味着您将拥有一个可以为许多用户包含许多不同容器的存储帐户。 If you want to have the application have the ability to upload to only one specific container while reading from many two options come to mind. 如果您希望应用程序能够上传到只有一个特定的容器,同时从脑海中读取两个选项。

First: Create a API that lives somewhere that handles all the requests. 第一:创建一个存在于处理所有请求的API的API。 Behind the API your code will have full access to entire storage account so your business logic will determine what they do and do not have access to. 在API后面,您的代码将拥有对整个存储帐户的完全访问权限,因此您的业务逻辑将确定他们执行和无权访问的内容。 The upside of this is that you don't have to create Shared Access Signatures (SAS) at all. 这样做的好处是您根本不必创建共享访问签名(SAS)。 Your app only knows how to talk to the API. 您的应用只知道如何与API通信。 You can even combine the data that they can see in that summary of content by doing parallel calls to get contents from the various containers from a single call from the application. 您甚至可以通过并行调用来组合他们可以在内容摘要中看到的数据,以便从应用程序的单个调用中获取来自各种容器的内容。 The downside is that you are now hosting this API service which has to broker ALL of these calls. 缺点是您现在正在托管此API服务,该服务必须代理所有这些调用。 You'd still need the API service to generate SAS if you go that route, but it would only be needed to generate the SAS and the client applications would make the calls directly with the Windows Azure storage service bearing the load which will reduce the resources you actually need. 如果你走这条路线,你仍然需要API服务来生成SAS,但只需要生成SAS,而客户端应用程序将直接使用带有负载的Windows Azure存储服务进行调用,这将减少资源你真的需要。

Second: Go the SAS route and generate SAS as needed, but this will get a bit tricky. 第二:走SAS路线并根据需要生成SAS,但这会有点棘手。

You can only create up to five Stored Access Policies on each container. 每个容器最多只能创建五个存储访问策略。 For one of these five you create one policy for the "owner" of the container which gives them Read and write permissions. 对于这五个中的一个,您为容器的“所有者”创建一个策略,该策略为其提供读写权限。 Now, since you are allowing folks to give read permissions to other folks you'll run into the policy count limit unless you reuse the same policy for Read, but then you won't be able to revoke it if the user removes someone from their "trusted" list of readers. 现在,由于您允许人们向其他人提供读取权限,您将遇到策略计数限制,除非您为Read重用相同的策略,但如果用户从他们中删除某人,您将无法撤销该权限“值得信赖”的读者名单。 For example, if I gave permissions to both Bob and James to my container and they are both handed a copy of the Read SAS, if I needed to remove Bob I'd have to cancel the Read Policy they shared and reissue a new Read SAS to James. 例如,如果我将Bob和James的权限授予我的容器并且他们都交给了Read SAS的副本,如果我需要删除Bob,我必须取消他们共享的Read Policy并重新发布一个新的Read SAS对詹姆斯 That's not really that bad of an issue though as the app can detect when it no longer has permissions and ask for the renewed SAS. 虽然应用程序可以检测到它何时不再拥有权限并要求更新SAS,但问题并不是那么糟糕。

In any case you still kind of want the policies to be short lived. 无论如何,你仍然希望政策是短暂的。 If I removed Bob from my trusted readers I'd pretty much want him cut off immediately. 如果我从可靠的读者那里删除了鲍勃,我非常希望他能立即切断。 This means you'll be going back to get a renewed SAS quite a bit and recreating the signed access signature which reduces the usefulness of the signed access policies. 这意味着您将重新获得更新的SAS并重新创建签名访问签名,这会降低签名访问策略的实用性。 This really depends on your stomach of how long you were planning on allowing the policy to live and how quickly you'd want someone cut off if they were "untrusted". 这实际上取决于你的胃,你计划允许政策生存多长时间以及如果他们“不信任”你想要有人切断的速度。

Now, a better option could be that you create Ad-hoc signatures. 现在,更好的选择可能是您创建Ad-hoc签名。 You can have as many Ad-hoc signatures as you want actually, but they can't be revoked and can at most last one hour. 您可以根据需要拥有尽可能多的Ad-hoc签名,但它们不能被撤销,最多可以持续一小时。 Since you'd make them short lived the length or lack of revocation shouldn't be an issue. 既然你让它们短暂,那么长度或缺乏撤销不应成为问题。 Going that route will mean that you'd be having the application come back to get them as needed, but given what I mentioned above about when someone is removed and you want the SAS to run out this may not be a big deal. 走这条路线意味着你会让应用程序回来根据需要得到它们,但考虑到我上面提到的关于何时被移除并且你希望SAS耗尽这可能不是什么大问题。 As you pointed out though, this does increase the complexity of things because you're generating a lot of SASs; 正如你所指出的那样,这确实增加了事物的复杂性,因为你生成了很多SAS; however, with these being ad-hoc you don't really need to track them. 然而,由于这些是临时的,你实际上并不需要跟踪它们。

If you were going to go the SAS route I'd suggest that your API be generating the ad-hoc ones as needed. 如果你打算走SAS路线,我建议你的API根据需要生成ad-hoc。 They shouldn't last more than a few minutes as people can have their permissions to a container removed and all you are trying to do is reduce the load on hosted service for actually doing the upload and download. 它们不应该持续超过几分钟,因为人们可以将其权限移除到容器中,而您尝试做的只是减少托管服务的负载以实际上传和下载。 Again, all the logic for handling what containers someone can see is still in your API service and the applications just get signatures they can use for small periods of time. 同样,处理某人可以看到的容器的所有逻辑仍然在您的API服务中,并且应用程序只获得可以在很短的时间内使用的签名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure Blob 存储共享访问签名 (SAS) - 签名不匹配 - Azure Blob Storage Shared Access Signature (SAS) - Signature did not match 如何为 Azure blob 存储中的文件夹生成共享访问签名? - How to generate a Shared access signature for a folder in Azure blob storage? 在img标签中为Azure Blob存储使用共享访问签名Uri - Using Shared Access Signature Uri in img tag for Azure Blob Storage Azure Blob存储生成无效的共享访问签名 - Azure Blob Storage Generates Invalid Shared Access Signature Azure blob容器共享访问签名到期 - Azure blob container shared access signature expiring Azure Blob:撤销共享访问签名策略 - Azure Blob: revoking Shared Access Signature Policy 没有API的Azure Blob共享访问签名 - Azure Blob Shared Access Signature without the api Azure Blob共享访问签名在生成新的存储访问密钥时是否起作用 - Azure Blob Shared Access Signature will work or not on generating new Storage Access Key Azure Powershell-如何使用“仅写”共享访问签名(SAS)将文件上传到Blob存储? - Azure Powershell - How to upload file to Blob Storage using “write-only” shared access signature (SAS)? 如何在Azure Blob存储中设置超过1年的共享访问签名 - How do you setup shared access signature with more than 1 year expiration at Azure blob storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM