Skip to content

Commit

Permalink
feat: update the auth in feat
Browse files Browse the repository at this point in the history
  • Loading branch information
wenytang-ms committed Feb 19, 2025
1 parent 51e942f commit 1c9f737
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 7 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.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "1.0.10",
"publisher": "ms-azuretools",
"icon": "resources/apim-icon-newone.png",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"aiKey": "20f6d4af-3678-4602-ae98-f6724f057cd5",
"engines": {
"vscode": "^1.50.1"
},
Expand Down 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 1c9f737

Please sign in to comment.