Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix two issues #391

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bug is that azure account return token as a deviceTokenCredentials, in vscode session not support for this, so we need to decode the jwt token.

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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this filed is align with azure account, debugging with azure account, this userId is user's email.

environment,
isCustomCloud: environment.name === "AzureCustomCloud",
};
Expand Down