Skip to content

Commit

Permalink
Use basic for password-store (#188692)
Browse files Browse the repository at this point in the history
* Use `basic` for `password-store`

Fixes #188059

* add to node argv.ts
  • Loading branch information
TylerLeonhardt authored Jul 24, 2023
1 parent a079961 commit 1ec506b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/vs/platform/encryption/common/encryptionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ export interface ICommonEncryptionService {
isEncryptionAvailable(): Promise<boolean>;
}

// The values provided to the `password-store` command line switch.
// Notice that they are not the same as the values returned by
// `getSelectedStorageBackend` in the `safeStorage` API.
export const enum PasswordStoreCLIOption {
kwallet = 'kwallet',
kwallet5 = 'kwallet5',
gnome = 'gnome',
gnomeKeyring = 'gnome-keyring',
gnomeLibsecret = 'gnome-libsecret',
basic = 'basic'
}

// The values returned by `getSelectedStorageBackend` in the `safeStorage` API.
export const enum KnownStorageProvider {
unknown = 'unknown',
basicText = 'basic_text',
Expand All @@ -37,6 +50,9 @@ export const enum KnownStorageProvider {
kwallet5 = 'kwallet5',
kwallet6 = 'kwallet6',

// The rest of these are not returned by `getSelectedStorageBackend`
// but these were added for platform completeness.

// Windows
dplib = 'dpapi',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { safeStorage as safeStorageElectron, app } from 'electron';
import { isMacintosh, isWindows } from 'vs/base/common/platform';
import { KnownStorageProvider, IEncryptionMainService } from 'vs/platform/encryption/common/encryptionService';
import { KnownStorageProvider, IEncryptionMainService, PasswordStoreCLIOption } from 'vs/platform/encryption/common/encryptionService';
import { ILogService } from 'vs/platform/log/common/log';

// These APIs are currently only supported in our custom build of electron so
Expand All @@ -25,7 +25,7 @@ export class EncryptionMainService implements IEncryptionMainService {
@ILogService private readonly logService: ILogService
) {
// if this commandLine switch is set, the user has opted in to using basic text encryption
if (app.commandLine.getSwitchValue('password-store') === 'basic_text') {
if (app.commandLine.getSwitchValue('password-store') === PasswordStoreCLIOption.basic) {
safeStorage.setUsePlainTextEncryption?.(true);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/environment/common/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export interface NativeParsedArgs {
'install-source'?: string;
'disable-updates'?: boolean;
'disable-keytar'?: boolean;
'password-store'?: string;
'disable-workspace-trust'?: boolean;
'disable-crash-reporter'?: boolean;
'crash-reporter-directory'?: string;
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/environment/node/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
'disable-telemetry': { type: 'boolean' },
'disable-updates': { type: 'boolean' },
'disable-keytar': { type: 'boolean' },
'password-store': { type: 'string' },
'disable-workspace-trust': { type: 'boolean' },
'disable-crash-reporter': { type: 'boolean' },
'crash-reporter-directory': { type: 'string' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isLinux } from 'vs/base/common/platform';
import Severity from 'vs/base/common/severity';
import { localize } from 'vs/nls';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IEncryptionService, KnownStorageProvider, isGnome, isKwallet } from 'vs/platform/encryption/common/encryptionService';
import { IEncryptionService, KnownStorageProvider, PasswordStoreCLIOption, isGnome, isKwallet } from 'vs/platform/encryption/common/encryptionService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ILogService } from 'vs/platform/log/common/log';
Expand Down Expand Up @@ -72,7 +72,7 @@ export class NativeSecretStorageService extends BaseSecretStorageService {
label: localize('usePlainText', "Use weaker encryption"),
run: async () => {
await this._encryptionService.setUsePlainTextEncryption();
await this._jsonEditingService.write(this._environmentService.argvResource, [{ path: ['password-store'], value: 'basic_text' }], true);
await this._jsonEditingService.write(this._environmentService.argvResource, [{ path: ['password-store'], value: PasswordStoreCLIOption.basic }], true);
this.reinitialize();
}
};
Expand Down

0 comments on commit 1ec506b

Please sign in to comment.