Fix missing kdf parameters in connector code (#4638)
This commit is contained in:
parent
cc5c753e30
commit
fa231499d6
|
@ -1,4 +1,5 @@
|
||||||
import { KdfType } from "../../../enums/kdfType";
|
import { KdfType } from "../../../enums/kdfType";
|
||||||
|
import { KdfConfig } from "../../domain/kdf-config";
|
||||||
import { KeysRequest } from "../keys.request";
|
import { KeysRequest } from "../keys.request";
|
||||||
|
|
||||||
export class SetKeyConnectorKeyRequest {
|
export class SetKeyConnectorKeyRequest {
|
||||||
|
@ -6,18 +7,22 @@ export class SetKeyConnectorKeyRequest {
|
||||||
keys: KeysRequest;
|
keys: KeysRequest;
|
||||||
kdf: KdfType;
|
kdf: KdfType;
|
||||||
kdfIterations: number;
|
kdfIterations: number;
|
||||||
|
kdfMemory?: number;
|
||||||
|
kdfParallelism?: number;
|
||||||
orgIdentifier: string;
|
orgIdentifier: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
key: string,
|
key: string,
|
||||||
kdf: KdfType,
|
kdf: KdfType,
|
||||||
kdfIterations: number,
|
kdfConfig: KdfConfig,
|
||||||
orgIdentifier: string,
|
orgIdentifier: string,
|
||||||
keys: KeysRequest
|
keys: KeysRequest
|
||||||
) {
|
) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.kdf = kdf;
|
this.kdf = kdf;
|
||||||
this.kdfIterations = kdfIterations;
|
this.kdfIterations = kdfConfig.iterations;
|
||||||
|
this.kdfMemory = kdfConfig.memory;
|
||||||
|
this.kdfParallelism = kdfConfig.parallelism;
|
||||||
this.orgIdentifier = orgIdentifier;
|
this.orgIdentifier = orgIdentifier;
|
||||||
this.keys = keys;
|
this.keys = keys;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,12 +85,13 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||||
async convertNewSsoUserToKeyConnector(tokenResponse: IdentityTokenResponse, orgId: string) {
|
async convertNewSsoUserToKeyConnector(tokenResponse: IdentityTokenResponse, orgId: string) {
|
||||||
const { kdf, kdfIterations, kdfMemory, kdfParallelism, keyConnectorUrl } = tokenResponse;
|
const { kdf, kdfIterations, kdfMemory, kdfParallelism, keyConnectorUrl } = tokenResponse;
|
||||||
const password = await this.cryptoFunctionService.randomBytes(64);
|
const password = await this.cryptoFunctionService.randomBytes(64);
|
||||||
|
const kdfConfig = new KdfConfig(kdfIterations, kdfMemory, kdfParallelism);
|
||||||
|
|
||||||
const k = await this.cryptoService.makeKey(
|
const k = await this.cryptoService.makeKey(
|
||||||
Utils.fromBufferToB64(password),
|
Utils.fromBufferToB64(password),
|
||||||
await this.tokenService.getEmail(),
|
await this.tokenService.getEmail(),
|
||||||
kdf,
|
kdf,
|
||||||
new KdfConfig(kdfIterations, kdfMemory, kdfParallelism)
|
kdfConfig
|
||||||
);
|
);
|
||||||
const keyConnectorRequest = new KeyConnectorUserKeyRequest(k.encKeyB64);
|
const keyConnectorRequest = new KeyConnectorUserKeyRequest(k.encKeyB64);
|
||||||
await this.cryptoService.setKey(k);
|
await this.cryptoService.setKey(k);
|
||||||
|
@ -110,7 +111,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||||
const setPasswordRequest = new SetKeyConnectorKeyRequest(
|
const setPasswordRequest = new SetKeyConnectorKeyRequest(
|
||||||
encKey[1].encryptedString,
|
encKey[1].encryptedString,
|
||||||
kdf,
|
kdf,
|
||||||
kdfIterations,
|
kdfConfig,
|
||||||
orgId,
|
orgId,
|
||||||
keys
|
keys
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue