Azure SAS 和权限
Azure SAS and Permission
GetSaSForBlobContainer(容器,SharedAccessBlobPermissions.List|SharedAccessBlobPermissions.Read);
public static string **GetSaSForBlobContainer**(CloudBlobContainer blobContainer, SharedAccessBlobPermissions permission)
{
var sas = blobContainer.GetSharedAccessSignature(new SharedAccessBlobPolicy()
{
Permissions = permission,
SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-5),//SAS Start time is back by 5 minutes to take clock skewness into consideration
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(15),
});
return string.Format(CultureInfo.InvariantCulture, "{0}{1}", blobContainer.Uri, sas);
}
-- 当我尝试此操作时,我的 stroge 帐户中的容器访问权限是 private.Can 我使用 Internet Explorer 列出容器中的 blob?我尝试使用 blob 和容器访问类型,但总是失败:
AuthenticationFailed
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:2c504f81-0001-00ea-3815-be7271000000 Time:2017-04-25T22:47:20.9382490Z
Signature did not match. String to sign used was rl 2017-04-25T22:38:15Z 2017-04-25T22:58:15Z /blob/onlineeducation/$root 2015-12-11
但是当我尝试这个时,我可以看到斑点,
foreach (IListBlobItem blob in blobs)
{
CloudBlockBlob blob1 = new CloudBlockBlob(blob.Uri);
string name = blob1.Name;
}
1-) 当我创建 GetSaSForBlobContainer 并且我的容器访问类型是私有时,我不明白一件事会发生什么(对于 Internet Explorer 和代码)?
2-) 当我在未经许可的情况下获取我的私有容器的引用,然后创建 blob uri + SAS.Example 会发生什么,我可以看到我的容器吗?或者我只能写引用的 blob(我的 blob 权限只有写)..
3-会发生什么,容器 uri + sas - Blob uri + sas(已读取权限)=> 我可以只上传文件还是可以在 Internet Explorer 中尝试时看到容器。
4-)这里有什么不同,
我的容器访问类型是 private 在我的存储中我得到了 continer 的引用,没有任何权限和 SAS ,然后使用 read 权限和 SAS 创建 blob URI。
我的存储中的容器访问类型是 private 我得到了容器的引用 with permssion 和 SAS,并且然后使用 read permssion 和 SAS
创建 blob URI
When I try this, my container access in my stroge account is
private.Can I list blobs in the container with Internet Explorer ? I
try with blob and container access types the fail is always
要解决此问题,请先在您的 SAS 中添加 List
作为权限,然后将 &restype=container&comp=list
添加到您的请求 URL 中。有关此问题的更多解释,请参阅此主题:Azure Shared Access Signature - Signature did not match.
1-) I dont understand one thing when I create GetSaSForBlobContainer
and my container access type is private what will happen (for Internet
Explorer and code) ?
除非你用它做点什么,否则什么都不会发生:)。根据 SAS 中包含的权限,拥有此 SAS URL 的用户将能够执行某些操作。例如,如果您创建具有 List
权限的 SAS,则用户将只能列出该容器中的 blob。他们甚至无法下载 blob(为此 SAS 必须包含 Read
权限)。
2-) When I get reference without permission my private container, and
then create blob uri + SAS.Example what will happen can I see my
containers ? or can I only write referenced blob (my blob permission
is only write)..
不,您看不到容器,因为 SAS 仅适用于容器。同样,因为您包含 Read
权限,您将只能读取 blob 内容。您将无法上传 blob。
3-What will happen, Container uri + sas - Blob uri + sas (Permission
is read) => Can I only upload the file or can I see the containers
when try in Internet Explorer .
不,拥有 Read
权限您无法上传文件。您甚至无法使用 Read
权限查看 blob 列表。为此,您需要 List
许可。
关于#4,在您实际使用该 SAS URL 之前没有任何区别。在第一种情况下你会得到一个错误,在第二种情况下你将能够看到 blob。
GetSaSForBlobContainer(容器,SharedAccessBlobPermissions.List|SharedAccessBlobPermissions.Read);
public static string **GetSaSForBlobContainer**(CloudBlobContainer blobContainer, SharedAccessBlobPermissions permission)
{
var sas = blobContainer.GetSharedAccessSignature(new SharedAccessBlobPolicy()
{
Permissions = permission,
SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-5),//SAS Start time is back by 5 minutes to take clock skewness into consideration
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(15),
});
return string.Format(CultureInfo.InvariantCulture, "{0}{1}", blobContainer.Uri, sas);
}
-- 当我尝试此操作时,我的 stroge 帐户中的容器访问权限是 private.Can 我使用 Internet Explorer 列出容器中的 blob?我尝试使用 blob 和容器访问类型,但总是失败:
AuthenticationFailed
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:2c504f81-0001-00ea-3815-be7271000000 Time:2017-04-25T22:47:20.9382490Z Signature did not match. String to sign used was rl 2017-04-25T22:38:15Z 2017-04-25T22:58:15Z /blob/onlineeducation/$root 2015-12-11
但是当我尝试这个时,我可以看到斑点,
foreach (IListBlobItem blob in blobs)
{
CloudBlockBlob blob1 = new CloudBlockBlob(blob.Uri);
string name = blob1.Name;
}
1-) 当我创建 GetSaSForBlobContainer 并且我的容器访问类型是私有时,我不明白一件事会发生什么(对于 Internet Explorer 和代码)?
2-) 当我在未经许可的情况下获取我的私有容器的引用,然后创建 blob uri + SAS.Example 会发生什么,我可以看到我的容器吗?或者我只能写引用的 blob(我的 blob 权限只有写)..
3-会发生什么,容器 uri + sas - Blob uri + sas(已读取权限)=> 我可以只上传文件还是可以在 Internet Explorer 中尝试时看到容器。
4-)这里有什么不同,
我的容器访问类型是 private 在我的存储中我得到了 continer 的引用,没有任何权限和 SAS ,然后使用 read 权限和 SAS 创建 blob URI。
我的存储中的容器访问类型是 private 我得到了容器的引用 with permssion 和 SAS,并且然后使用 read permssion 和 SAS
创建 blob URI
When I try this, my container access in my stroge account is private.Can I list blobs in the container with Internet Explorer ? I try with blob and container access types the fail is always
要解决此问题,请先在您的 SAS 中添加 List
作为权限,然后将 &restype=container&comp=list
添加到您的请求 URL 中。有关此问题的更多解释,请参阅此主题:Azure Shared Access Signature - Signature did not match.
1-) I dont understand one thing when I create GetSaSForBlobContainer and my container access type is private what will happen (for Internet Explorer and code) ?
除非你用它做点什么,否则什么都不会发生:)。根据 SAS 中包含的权限,拥有此 SAS URL 的用户将能够执行某些操作。例如,如果您创建具有 List
权限的 SAS,则用户将只能列出该容器中的 blob。他们甚至无法下载 blob(为此 SAS 必须包含 Read
权限)。
2-) When I get reference without permission my private container, and then create blob uri + SAS.Example what will happen can I see my containers ? or can I only write referenced blob (my blob permission is only write)..
不,您看不到容器,因为 SAS 仅适用于容器。同样,因为您包含 Read
权限,您将只能读取 blob 内容。您将无法上传 blob。
3-What will happen, Container uri + sas - Blob uri + sas (Permission is read) => Can I only upload the file or can I see the containers when try in Internet Explorer .
不,拥有 Read
权限您无法上传文件。您甚至无法使用 Read
权限查看 blob 列表。为此,您需要 List
许可。
关于#4,在您实际使用该 SAS URL 之前没有任何区别。在第一种情况下你会得到一个错误,在第二种情况下你将能够看到 blob。