mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Notify STS when encryption keys are updated in azurecore (#22384)
This commit is contained in:
@@ -9,12 +9,14 @@ import * as vscode from 'vscode';
|
||||
import { AuthLibrary } from '../../constants';
|
||||
import * as LocalizedConstants from '../../localizedConstants';
|
||||
import { Logger } from '../../utils/Logger';
|
||||
import { CacheEncryptionKeys } from 'azurecore';
|
||||
|
||||
export class FileEncryptionHelper {
|
||||
constructor(
|
||||
private readonly _authLibrary: AuthLibrary,
|
||||
private readonly _credentialService: azdata.CredentialProvider,
|
||||
protected readonly _fileName: string
|
||||
protected readonly _fileName: string,
|
||||
private readonly _onEncryptionKeysUpdated?: vscode.EventEmitter<CacheEncryptionKeys>
|
||||
) {
|
||||
this._algorithm = this._authLibrary === AuthLibrary.MSAL ? 'aes-256-cbc' : 'aes-256-gcm';
|
||||
this._bufferEncoding = this._authLibrary === AuthLibrary.MSAL ? 'utf16le' : 'hex';
|
||||
@@ -48,6 +50,14 @@ export class FileEncryptionHelper {
|
||||
this._ivBuffer = Buffer.from(iv, this._bufferEncoding);
|
||||
this._keyBuffer = Buffer.from(key, this._bufferEncoding);
|
||||
}
|
||||
|
||||
// Emit event with cache encryption keys to send notification to provider services.
|
||||
if (this._authLibrary === AuthLibrary.MSAL && this._onEncryptionKeysUpdated) {
|
||||
this._onEncryptionKeysUpdated.fire({
|
||||
iv: this._ivBuffer.toString(this._bufferEncoding),
|
||||
key: this._keyBuffer.toString(this._bufferEncoding)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fileSaver = async (content: string): Promise<string> => {
|
||||
|
||||
@@ -9,18 +9,21 @@ import { promises as fsPromises } from 'fs';
|
||||
import * as lockFile from 'lockfile';
|
||||
import * as path from 'path';
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { AccountsClearTokenCacheCommand, AuthLibrary } from '../../constants';
|
||||
import { Logger } from '../../utils/Logger';
|
||||
import { FileEncryptionHelper } from './fileEncryptionHelper';
|
||||
import { CacheEncryptionKeys } from 'azurecore';
|
||||
|
||||
export class MsalCachePluginProvider {
|
||||
constructor(
|
||||
private readonly _serviceName: string,
|
||||
private readonly _msalFilePath: string,
|
||||
private readonly _credentialService: azdata.CredentialProvider
|
||||
private readonly _credentialService: azdata.CredentialProvider,
|
||||
private readonly _onEncryptionKeysUpdated: vscode.EventEmitter<CacheEncryptionKeys>
|
||||
) {
|
||||
this._msalFilePath = path.join(this._msalFilePath, this._serviceName);
|
||||
this._fileEncryptionHelper = new FileEncryptionHelper(AuthLibrary.MSAL, this._credentialService, this._serviceName);
|
||||
this._fileEncryptionHelper = new FileEncryptionHelper(AuthLibrary.MSAL, this._credentialService, this._serviceName, this._onEncryptionKeysUpdated);
|
||||
}
|
||||
|
||||
private _lockTaken: boolean = false;
|
||||
|
||||
Reference in New Issue
Block a user