mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
* quick draft PR for not throwing when looking for a chunked password * update comment with more info Co-authored-by: Ian Huff <ianhuff@Ians-MacBook-Pro.local> Co-authored-by: Ian Huff <ianhu@microsoft.com> Co-authored-by: Ian Huff <ianhuff@Ians-MacBook-Pro.local>
This commit is contained in:
@@ -150,19 +150,28 @@ export abstract class BaseCredentialsMainService extends Disposable implements I
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const didDelete = await keytar.deletePassword(service, account);
|
const didDelete = await keytar.deletePassword(service, account);
|
||||||
let { content, hasNextChunk }: ChunkedPassword = JSON.parse(password);
|
try {
|
||||||
if (content && hasNextChunk) {
|
let { content, hasNextChunk }: ChunkedPassword = JSON.parse(password);
|
||||||
// need to delete additional chunks
|
if (content && hasNextChunk) {
|
||||||
let index = 1;
|
// need to delete additional chunks
|
||||||
while (hasNextChunk) {
|
let index = 1;
|
||||||
const accountWithIndex = `${account}-${index}`;
|
while (hasNextChunk) {
|
||||||
const nextChunk = await keytar.getPassword(service, accountWithIndex);
|
const accountWithIndex = `${account}-${index}`;
|
||||||
await keytar.deletePassword(service, accountWithIndex);
|
const nextChunk = await keytar.getPassword(service, accountWithIndex);
|
||||||
|
await keytar.deletePassword(service, accountWithIndex);
|
||||||
|
|
||||||
const result: ChunkedPassword = JSON.parse(nextChunk!);
|
const result: ChunkedPassword = JSON.parse(nextChunk!);
|
||||||
hasNextChunk = result.hasNextChunk;
|
hasNextChunk = result.hasNextChunk;
|
||||||
index++;
|
index++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
// When the password is saved the entire JSON payload is encrypted then stored, thus the result from getPassword might not be valid JSON
|
||||||
|
// https://github.com/microsoft/vscode/blob/c22cb87311b5eb1a3bf5600d18733f7485355dc0/src/vs/workbench/api/browser/mainThreadSecretState.ts#L83
|
||||||
|
// However in the chunked case we JSONify each chunk after encryption so for the chunked case we do expect valid JSON here
|
||||||
|
// https://github.com/microsoft/vscode/blob/708cb0c507d656b760f9d08115b8ebaf8964fd73/src/vs/platform/credentials/common/credentialsMainService.ts#L128
|
||||||
|
// Empty catch here just as in getPassword because we expect to handle both JSON cases and non JSON cases here it's not an error case to fail to parse
|
||||||
|
// https://github.com/microsoft/vscode/blob/708cb0c507d656b760f9d08115b8ebaf8964fd73/src/vs/platform/credentials/common/credentialsMainService.ts#L76
|
||||||
}
|
}
|
||||||
|
|
||||||
if (didDelete) {
|
if (didDelete) {
|
||||||
|
|||||||
Reference in New Issue
Block a user