【问题标题】:How to revoke Azure's Shared Access Signature (SAS) with nodejs, after finished file upload?完成文件上传后,如何使用 nodejs 撤销 Azure 的共享访问签名(SAS)?
【发布时间】:2022-01-07 21:48:08
【问题描述】:

我能够使用

生成 SAS 令牌

import { generateBlobSASQueryParameters } from '@azure/storage-blob';

function generateUploadUrl(){
    const startsOn = new Date();
    const expiresOn =  new Date(startsOn.valueOf() + 60 * 60 * 1000);
    const userDelegationKey = await this.blobServiceClient.getUserDelegationKey(startsOn, expiresOn);

    const queryParams = generateBlobSASQueryParameters({    // HERE
        containerName
        permissions: BlobSASPermissions.parse('racwd'),
        startsOn,
        expiresOn,
    }, userDelegationKey, this.storageAccount);

    const token = queryParams.toString();
    return `https://${this.storageAccount}.blob.core.windows.net/${this.containerName}/?${token}`;
}

感谢我能够使用此链接上传文件:

import { ContainerClient } from '@azure/storage-blob';

function uploadFile(localFilePath: string){
    const containerClient = new ContainerClient(generatedUrl);
    const blockBlobClient = containerClient.getBlockBlobClient(blobName);
    await blockBlobClient.uploadFile(localFilePath);
}

现在,文件上传完成后,我想撤销 SAS 令牌,不允许进一步上传到 blob。 我该怎么做?我找不到任何相关示例/信息。

【问题讨论】:

    标签: node.js azure azure-blob-storage azure-sas


    【解决方案1】:

    您不能直接撤销 SAS 令牌。但是您可以撤销用户委托密钥,这将使所有用它签名的令牌无效。

    我实际上没有看到 .NET 方法,但您可以使用 REST APIPowerShellCLI 来实现。

    【讨论】:

      猜你喜欢
      • 2014-11-30
      • 1970-01-01
      • 2015-10-29
      • 2012-11-21
      • 2016-04-16
      • 1970-01-01
      • 2020-05-09
      • 2018-03-10
      • 1970-01-01
      相关资源
      最近更新 更多