Skip to content
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

Use basic for password-store #188692

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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