Skip to content

Commit a4d4857

Browse files
Notify user once when Encryption isn't available (microsoft#185390)
And point to troubleshooting doc. ref microsoft#185212
1 parent 5de3dd3 commit a4d4857

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/vs/platform/secrets/common/secrets.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55

66
import { SequencerByKey } from 'vs/base/common/async';
77
import { IEncryptionService } from 'vs/platform/encryption/common/encryptionService';
8-
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
8+
import { IInstantiationService, createDecorator } from 'vs/platform/instantiation/common/instantiation';
99
import { IStorageService, InMemoryStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
1010
import { Event, PauseableEmitter } from 'vs/base/common/event';
1111
import { ILogService } from 'vs/platform/log/common/log';
12+
import { isNative } from 'vs/base/common/platform';
13+
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
14+
import { localize } from 'vs/nls';
15+
import { IOpenerService } from 'vs/platform/opener/common/opener';
16+
import { once } from 'vs/base/common/functional';
1217

1318
export const ISecretStorageService = createDecorator<ISecretStorageService>('secretStorageService');
1419

@@ -40,7 +45,9 @@ export class SecretStorageService implements ISecretStorageService {
4045
constructor(
4146
@IStorageService private _storageService: IStorageService,
4247
@IEncryptionService private _encryptionService: IEncryptionService,
43-
@ILogService private readonly _logService: ILogService,
48+
@IInstantiationService private readonly _instantiationService: IInstantiationService,
49+
@INotificationService private readonly _notificationService: INotificationService,
50+
@ILogService private readonly _logService: ILogService
4451
) {
4552
this._storageService.onDidChangeValue(e => this.onDidChangeValue(e.key));
4653
}
@@ -89,6 +96,10 @@ export class SecretStorageService implements ISecretStorageService {
8996
return this._sequencer.queue(key, async () => {
9097
await this.initialized;
9198

99+
if (isNative && this.type !== 'persisted') {
100+
this.notifyNativeUserOnce();
101+
}
102+
92103
const encrypted = await this._encryptionService.encrypt(value);
93104
const fullKey = this.getKey(key);
94105
try {
@@ -129,4 +140,20 @@ export class SecretStorageService implements ISecretStorageService {
129140
private getKey(key: string): string {
130141
return `${this._storagePrefix}${key}`;
131142
}
143+
144+
private notifyNativeUserOnce = once(() => this.notifyNativeUser());
145+
private notifyNativeUser(): void {
146+
this._notificationService.prompt(
147+
Severity.Warning,
148+
localize('notEncrypted', 'Secrets are not being stored on disk because encryption is not available in this environment.'),
149+
[{
150+
label: localize('openTroubleshooting', "Open Troubleshooting"),
151+
run: () => this._instantiationService.invokeFunction(accessor => {
152+
const openerService = accessor.get(IOpenerService);
153+
// Open troubleshooting docs page
154+
return openerService.open('https://go.microsoft.com/fwlink/?linkid=2239490');
155+
})
156+
}]
157+
);
158+
}
132159
}

src/vs/workbench/services/secrets/browser/secretStorageService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
import { IEncryptionService } from 'vs/platform/encryption/common/encryptionService';
77
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
8+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
89
import { ILogService } from 'vs/platform/log/common/log';
10+
import { INotificationService } from 'vs/platform/notification/common/notification';
911
import { ISecretStorageProvider, ISecretStorageService, SecretStorageService } from 'vs/platform/secrets/common/secrets';
1012
import { IStorageService } from 'vs/platform/storage/common/storage';
1113
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
@@ -18,9 +20,11 @@ export class BrowserSecretStorageService extends SecretStorageService {
1820
@IStorageService storageService: IStorageService,
1921
@IEncryptionService encryptionService: IEncryptionService,
2022
@IBrowserWorkbenchEnvironmentService environmentService: IBrowserWorkbenchEnvironmentService,
23+
@IInstantiationService instantiationService: IInstantiationService,
24+
@INotificationService notificationService: INotificationService,
2125
@ILogService logService: ILogService
2226
) {
23-
super(storageService, encryptionService, logService);
27+
super(storageService, encryptionService, instantiationService, notificationService, logService);
2428

2529
if (environmentService.options?.secretStorageProvider) {
2630
this._secretStorageProvider = environmentService.options.secretStorageProvider;

0 commit comments

Comments
 (0)