Skip to content

Commit

Permalink
Support Bearer tokens for managing blobs, file shares, queues, and ta…
Browse files Browse the repository at this point in the history
…bles (#1339)

* WIP for using a token for auth

* Enable bearer token access to blob, queue, and tables

* Reset launch.json

* Restore lock

* Remove some unneeded changes

* Remove azcopy from lock

* Use beta file-share to enable OAuth access

* Use beta file-share to enable OAuth access

* Fix package-lock.json
  • Loading branch information
nturinski authored Sep 13, 2024
1 parent 7e6d2c0 commit 3386da2
Show file tree
Hide file tree
Showing 25 changed files with 301 additions and 197 deletions.
179 changes: 126 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@
"@azure/data-tables": "^13.0.0",
"@azure/storage-blob": "^12.1.1",
"@azure/storage-file-datalake": "^12.1.1",
"@azure/storage-file-share": "^12.1.1",
"@azure/storage-file-share": "^12.25.0-beta.1",
"@azure/storage-queue": "^12.7.0",
"@microsoft/vscode-azext-azureappservice": "^0.7.0",
"@microsoft/vscode-azext-azureutils": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/AttachedAccountRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class AttachedAccountRoot implements ISubscriptionContext {
throw this._error;
}

public createCredentialsForScopes(): never {
public get createCredentialsForScopes(): never {
throw this._error;
}

Expand Down
12 changes: 6 additions & 6 deletions src/AzureStorageFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export class AzureStorageFS implements vscode.FileSystemProvider, vscode.TextDoc
static async showEditor(context: IActionContext, treeItem: BlobTreeItem | FileTreeItem): Promise<void> {
let client: BlockBlobClient | ShareFileClient;
if (treeItem instanceof BlobTreeItem) {
client = createBlockBlobClient(treeItem.root, treeItem.container.name, treeItem.blobPath);
client = await createBlockBlobClient(treeItem.root, treeItem.container.name, treeItem.blobPath);
} else {
client = createFileClient(treeItem.root, treeItem.shareName, treeItem.directoryPath, treeItem.fileName);
client = await createFileClient(treeItem.root, treeItem.shareName, treeItem.directoryPath, treeItem.fileName);
}

const uri = this.idToUri(treeItem.fullId);
Expand Down Expand Up @@ -137,10 +137,10 @@ export class AzureStorageFS implements vscode.FileSystemProvider, vscode.TextDoc
let props: (BlobGetPropertiesResponse & FileGetPropertiesResponse) | undefined;
try {
if (treeItem instanceof BlobTreeItem) {
const blockBlobClient: BlockBlobClient = createBlockBlobClient(treeItem.root, treeItem.container.name, treeItem.blobPath);
const blockBlobClient: BlockBlobClient = await createBlockBlobClient(treeItem.root, treeItem.container.name, treeItem.blobPath);
props = await blockBlobClient.getProperties();
} else if (treeItem instanceof FileTreeItem) {
const fileClient: ShareFileClient = createFileClient(treeItem.root, treeItem.shareName, treeItem.directoryPath, treeItem.fileName);
const fileClient: ShareFileClient = await createFileClient(treeItem.root, treeItem.shareName, treeItem.directoryPath, treeItem.fileName);
props = await fileClient.getProperties();
}
} catch (error) {
Expand Down Expand Up @@ -241,10 +241,10 @@ export class AzureStorageFS implements vscode.FileSystemProvider, vscode.TextDoc
try {
let buffer: Buffer;
if (treeItem instanceof FileShareTreeItem) {
client = createFileClient(treeItem.root, treeItem.shareName, parsedUri.parentDirPath, parsedUri.baseName);
client = await createFileClient(treeItem.root, treeItem.shareName, parsedUri.parentDirPath, parsedUri.baseName);
buffer = await client.downloadToBuffer();
} else {
client = createBlobClient(treeItem.root, treeItem.container.name, parsedUri.filePath);
client = await createBlobClient(treeItem.root, treeItem.container.name, parsedUri.filePath);
buffer = await client.downloadToBuffer();
}
return buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/BlobContainerFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class BlobContainerFS implements vscode.FileSystemProvider {
}

static async showEditor(context: IActionContext, treeItem: BlobTreeItem): Promise<void> {
const client: BlockBlobClient = createBlockBlobClient(treeItem.root, treeItem.container.name, treeItem.blobPath);
const client: BlockBlobClient = await createBlockBlobClient(treeItem.root, treeItem.container.name, treeItem.blobPath);

const uri = BlobContainerFS.idToUri(treeItem.fullId);
const properties: BlobGetPropertiesResponse = await client.getProperties();
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deleteBlob/DeleteBlobStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class DeleteBlobStep extends AzureWizardExecuteStep<IDeleteBlobWizardCont
const deletingBlob: string = localize('deletingBlob', 'Deleting blob "{0}"...', blobName);
ext.outputChannel.appendLog(deletingBlob);
progress.report({ message: deletingBlob });
const blobClient: BlobClient = createBlobClient(blob.root, blob.container.name, blob.blobPath);
const blobClient: BlobClient = await createBlobClient(blob.root, blob.container.name, blob.blobPath);
await blobClient.delete();
const deleteSuccessful: string = localize('successfullyDeletedBlob', 'Successfully deleted blob "{0}".', blobName);
ext.outputChannel.appendLog(deleteSuccessful);
Expand Down
Loading

0 comments on commit 3386da2

Please sign in to comment.