Skip to content

Work correctly with authentication that is case-sensitive on username (fix #1593) #1598

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 4 commits into from
Jun 26, 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
33 changes: 10 additions & 23 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,6 @@ 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 @@ -292,27 +287,19 @@ 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 = <ServerManagerAuthSession>await vscode.authentication.getSession(
serverManager.AUTHENTICATION_PROVIDER,
scopes,
{
silent: true,
account,
}
);
let session = 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,
}
);
session = 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.userName;
// If original spec lacked username use the one obtained from the user by the authprovider (exact case)
serverSpec.username = serverSpec.username || session.scopes[1];
serverSpec.password = session.accessToken;
}
}
Expand Down