Skip to content

Commit

Permalink
fix: fix two issues (#391)
Browse files Browse the repository at this point in the history
* feat: update the auth in feat

* fix: update

* fix: update
  • Loading branch information
wenytang-ms authored Feb 19, 2025
1 parent 51e942f commit 8b27871
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 6 deletions.
184 changes: 183 additions & 1 deletion package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@
"@microsoft/vscode-azext-dev": "^2.1.0",
"@types/fs-extra": "^4.0.3",
"@types/gulp": "^4.0.6",
"@types/jsonwebtoken": "^9.0.8",
"@types/mocha": "^10.0.0",
"@types/node": "^8.10.59",
"@types/request": "^2.48.4",
Expand Down Expand Up @@ -873,6 +874,7 @@
"guid-typescript": "^1.0.9",
"gulp-decompress": "^3.0.0",
"gulp-download": "0.0.1",
"jsonwebtoken": "^9.0.2",
"opn": "^5.3.0",
"request": "^2.88.2",
"request-promise": "^4.2.5",
Expand All @@ -890,4 +892,4 @@
"overrides": {
"fsevents": "~2.3.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AuthorizationTreeItem } from "../../explorer/AuthorizationTreeItem";
import { ext } from "../../extensionVariables";
import { localize } from "../../localize";
import { nonNullValue } from "../../utils/nonNull";
import * as jwt from "jsonwebtoken";

const systemAssignedManagedIdentitiesOptionLabel = "System assigned managed identity";
const userAssignedManagedIdentitiesOptionLabel = "User assigned managed identity";
Expand Down Expand Up @@ -154,9 +155,10 @@ async function populateIdentityOptionsAsync(

// 1. Self
const token = await credential.getToken();
const decoded = jwt.decode(token.token, { complete: true }) as any;
const meOption : QuickPickItem = {
label: nonNullValue(token.userId),
description: token.oid,
label: nonNullValue(decoded.payload!.unique_name!),
description: decoded.payload!.oid,
detail: "Current signedIn user"
};
options.push(meOption);
Expand Down
4 changes: 2 additions & 2 deletions src/explorer/AzureAccountTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class AzureAccountTreeItem extends AzExtParentTreeItem {
session: vscode.AuthenticationSession,
subscription: Subscription,
): ISubscriptionContext {
const credentials = AzureAuth.getCredential(sessionProvider);
const credentials = AzureAuth.getCredential(sessionProvider);
const environment = AzureAuth.getEnvironment();

return {
Expand All @@ -190,7 +190,7 @@ export class AzureAccountTreeItem extends AzExtParentTreeItem {
subscriptionId: subscription.subscriptionId || "",
subscriptionPath: `/subscriptions/${subscription.subscriptionId}`,
tenantId: subscription.tenantId || "",
userId: session.account.id,
userId: session.account.label,
environment,
isCustomCloud: environment.name === "AzureCustomCloud",
};
Expand Down

0 comments on commit 8b27871

Please sign in to comment.