encrypt sensitive data
MODIFY
src/server/oicp/OICPUtils.ts
src/server/oicp/OICPUtils.ts
@@ -198,23 +198,4 @@ export default class OICPUtils {
await UserStorage.saveUserStatus(tenantID, newVirtualOICPUser.id, UserStatus.ACTIVE);
}
- public static async encryptCertificates(tenantID: string, oicpSetting: OicpSetting): Promise<void> {
- const roamingSettings = await SettingStorage.getOICPSettings(tenantID);
- // Encrypt key and certificate if not already encrypted
- // CPO
- if (oicpSetting.cpo.key && roamingSettings.oicp.cpo?.key !== oicpSetting.cpo.key) {
- oicpSetting.cpo.key = await sanitize(Cypher.encrypt(tenantID, oicpSetting.cpo.key));
- }
- if (oicpSetting.cpo.cert && roamingSettings.oicp.cpo?.cert !== oicpSetting.cpo.cert) {
- oicpSetting.cpo.cert = await sanitize(Cypher.encrypt(tenantID, oicpSetting.cpo.cert));
- }
-
- // EMSP
- if (oicpSetting.emsp.key && roamingSettings.oicp.emsp?.key !== oicpSetting.emsp.key) {
- oicpSetting.emsp.key = await sanitize(Cypher.encrypt(tenantID, oicpSetting.emsp.key));
- }
- if (oicpSetting.emsp.cert && roamingSettings.oicp.emsp?.cert !== oicpSetting.emsp.cert) {
- oicpSetting.emsp.cert = await sanitize(Cypher.encrypt(tenantID, oicpSetting.emsp.cert));
- }
- }
}

MODIFY
src/server/rest/v1/service/SettingService.ts
src/server/rest/v1/service/SettingService.ts
@@ -156,9 +156,6 @@ export default class SettingService {
}
// Filter
const filteredRequest = SettingSecurity.filterSettingCreateRequest(req.body);
- if (filteredRequest.content.oicp?.cpo?.cert) {
- await OICPUtils.encryptCertificates(req.user.tenantID, filteredRequest.content.oicp);
- }
// Process the sensitive data if any
await Cypher.encryptSensitiveDataInJSON(req.user.tenantID, filteredRequest);
// Update timestamp
@@ -182,9 +179,6 @@ export default class SettingService {
public static async handleUpdateSetting(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
const settingUpdate = SettingSecurity.filterSettingUpdateRequest(req.body);
- if (settingUpdate.content.oicp?.cpo?.cert) {
- await OICPUtils.encryptCertificates(req.user.tenantID, settingUpdate.content.oicp);
- }
UtilsService.assertIdIsProvided(action, settingUpdate.id, MODULE_NAME, 'handleUpdateSetting', req.user);
// Check auth
if (!Authorizations.canUpdateSetting(req.user)) {

encrypt sensitive data