Skip to content

Retrieve password from Server Manager case-sensitively #1596

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

Merged
merged 1 commit into from
Jun 24, 2025
Merged
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
31 changes: 22 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ export async function resolveConnectionSpec(serverName: string, uri?: vscode.Uri
}
}

interface ServerManagerAuthSession extends vscode.AuthenticationSession {
serverName: string;
userName: string;
}

async function resolvePassword(serverSpec, ignoreUnauthenticated = false): Promise<void> {
if (
// Connection isn't unauthenticated
Expand All @@ -287,19 +292,27 @@ async function resolvePassword(serverSpec, ignoreUnauthenticated = false): Promi
// Handle Server Manager extension version < 3.8.0
const account = serverManagerApi.getAccount ? serverManagerApi.getAccount(serverSpec) : undefined;

let session = await vscode.authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, {
silent: true,
account,
});
if (!session) {
session = await vscode.authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, {
createIfNone: true,
let session = <ServerManagerAuthSession>await vscode.authentication.getSession(
serverManager.AUTHENTICATION_PROVIDER,
scopes,
{
silent: true,
account,
});
}
);
if (!session) {
session = <ServerManagerAuthSession>await vscode.authentication.getSession(
serverManager.AUTHENTICATION_PROVIDER,
scopes,
{
createIfNone: true,
account,
}
);
}
if (session) {
// If original spec lacked username use the one obtained by the authprovider
serverSpec.username = serverSpec.username || session.scopes[1];
serverSpec.username = serverSpec.username || session.userName;
serverSpec.password = session.accessToken;
}
}
Expand Down