From 3f77832e4b64974e7aff601b2dad2a0078f1b8f8 Mon Sep 17 00:00:00 2001 From: Amir Omidi Date: Tue, 14 Apr 2020 14:48:38 -0700 Subject: [PATCH] Don't enforce the password limit for file keytar (#9974) * Allow users to use file based keychain if they have to * Don't enforce this limit for FS keytar * Spacing --- extensions/azurecore/src/account-provider/simpleTokenCache.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/azurecore/src/account-provider/simpleTokenCache.ts b/extensions/azurecore/src/account-provider/simpleTokenCache.ts index a8c3d58e20..b4d9edfd31 100644 --- a/extensions/azurecore/src/account-provider/simpleTokenCache.ts +++ b/extensions/azurecore/src/account-provider/simpleTokenCache.ts @@ -141,7 +141,7 @@ export class SimpleTokenCache { } async saveCredential(id: string, key: string): Promise { - if (key.length > 2500) { // Windows limitation + if (!this.forceFileStorage && key.length > 2500) { // Windows limitation throw new Error('Key length is longer than 2500 chars'); } @@ -159,9 +159,11 @@ export class SimpleTokenCache { async getCredential(id: string): Promise { try { const result = await this.keytar.getPassword(this.serviceName, id); + if (result === null) { return undefined; } + return result; } catch (ex) { console.log(`Getting key failed: ${ex}`);