Skip to content

Commit

Permalink
Fall back to basic auth when kerberos errors out (#220034)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Jul 5, 2024
1 parent 3a0cc23 commit ea8d37e
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions src/vs/workbench/api/node/proxyResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,29 +173,28 @@ async function lookupProxyAuthorization(
} catch (err) {
extHostLogService.error('ProxyResolver#lookupProxyAuthorization Kerberos authentication failed', err);
}
} else {
const header = authenticate.find(a => /^Basic( |$)/i.test(a));
if (header) {
try {
state.basicAuthAttempt = (state.basicAuthAttempt || 0) + 1;
const realm = / realm="([^"]+)"/i.exec(header)?.[1];
extHostLogService.debug('ProxyResolver#lookupProxyAuthorization Basic authentication lookup', `proxyURL:${proxyURL}`, `realm:${realm}`);
const url = new URL(proxyURL);
const authInfo: AuthInfo = {
scheme: 'basic',
host: url.hostname,
port: Number(url.port),
realm: realm || '',
isProxy: true,
attempt: state.basicAuthAttempt,
};
const credentials = await extHostWorkspace.lookupAuthorization(authInfo);
if (credentials) {
return 'Basic ' + Buffer.from(`${credentials.username}:${credentials.password}`).toString('base64');
}
} catch (err) {
extHostLogService.error('ProxyResolver#lookupProxyAuthorization Kerberos authentication failed', err);
}
const basicAuthHeader = authenticate.find(a => /^Basic( |$)/i.test(a));
if (basicAuthHeader) {
try {
state.basicAuthAttempt = (state.basicAuthAttempt || 0) + 1;
const realm = / realm="([^"]+)"/i.exec(basicAuthHeader)?.[1];
extHostLogService.debug('ProxyResolver#lookupProxyAuthorization Basic authentication lookup', `proxyURL:${proxyURL}`, `realm:${realm}`);
const url = new URL(proxyURL);
const authInfo: AuthInfo = {
scheme: 'basic',
host: url.hostname,
port: Number(url.port),
realm: realm || '',
isProxy: true,
attempt: state.basicAuthAttempt,
};
const credentials = await extHostWorkspace.lookupAuthorization(authInfo);
if (credentials) {
return 'Basic ' + Buffer.from(`${credentials.username}:${credentials.password}`).toString('base64');
}
} catch (err) {
extHostLogService.error('ProxyResolver#lookupProxyAuthorization Kerberos authentication failed', err);
}
}
return undefined;
Expand Down

0 comments on commit ea8d37e

Please sign in to comment.