Commit 0cb88f3e authored by Varunkumar Manohar's avatar Varunkumar Manohar
Browse files

fix: use service appkey instead of forwarding the client appkey to ccm user-assoc-svc

parent c3982b36
Pipeline #70392 passed with stages
in 9 minutes and 41 seconds
......@@ -15,7 +15,6 @@
// ============================================================================
import request from 'request-promise';
import { AuthProviderFactory } from '../auth';
import { Config, DataEcosystemCoreFactory } from '../cloud';
import { Cache, Error } from '../shared';
......@@ -27,7 +26,7 @@ export class DESUserAssociation {
// User association details cached for an hour
private static _cacheEntryTTL = 3600;
public static async convertSubIdToEmail(appkey: string, subId: string, dataPartitionID: string): Promise<string> {
public static async convertSubIdToEmail(subId: string, dataPartitionID: string): Promise<string> {
if (!this._cache) {
this._cache = new Cache<string>('subid-to-email-mapping');
......@@ -48,7 +47,7 @@ export class DESUserAssociation {
const options = {
headers: {
'Accept': 'application/json',
'AppKey': appkey || Config.DES_SERVICE_APPKEY,
'AppKey': Config.DES_SERVICE_APPKEY,
'Authorization': 'Bearer ' + credential.access_token,
'Content-Type': 'application/json'
},
......
......@@ -16,11 +16,10 @@
import { Request as expRequest, Response as expResponse } from 'express';
import { v4 as uuidv4 } from 'uuid';
import { DatasetModel } from '.';
import { Auth } from '../../auth';
import { Config, JournalFactoryTenantClient, LoggerFactory, StorageFactory } from '../../cloud';
import { DESStorage, DESUtils, DESUserAssociation } from '../../dataecosystem';
import { DESStorage, DESUserAssociation, DESUtils } from '../../dataecosystem';
import { Error, Feature, FeatureFlags, Params, Response, Utils } from '../../shared';
import { SubProjectDAO, SubProjectModel } from '../subproject';
import { TenantDAO, TenantModel } from '../tenant';
......@@ -29,6 +28,7 @@ import { IWriteLockSession, Locker } from './locker';
import { DatasetOP } from './optype';
import { DatasetParser } from './parser';
export class DatasetHandler {
// handler for the [ /dataset ] endpoints
......@@ -252,13 +252,13 @@ export class DatasetHandler {
} catch (err) {
// rollback
if(datasetRegisteredConsistencyFlag) {
if (datasetRegisteredConsistencyFlag) {
const datasetCheck = subproject.enforce_key ?
await DatasetDAO.getByKey(journalClient, dataset) :
(await DatasetDAO.get(journalClient, dataset))[0];
if(datasetCheck) {
if (datasetCheck) {
await DatasetDAO.delete(journalClient, datasetCheck);
if(datasetCheck.seismicmeta_guid) {
if (datasetCheck.seismicmeta_guid) {
await DESStorage.deleteRecord(
req.headers.authorization, datasetCheck.last_modified_date,
tenant.esd, req[Config.DE_FORWARD_APPKEY]);
......@@ -328,8 +328,7 @@ export class DatasetHandler {
if (FeatureFlags.isEnabled(Feature.CCM_INTERACTION) && convertSubIdToEmail) {
if (!Utils.isEmail(datasetOUT.created_by)) {
const dataPartition = DESUtils.getDataPartitionID(tenant.esd);
const userEmail = await DESUserAssociation.convertSubIdToEmail
(req[Config.DE_FORWARD_APPKEY], datasetOUT.created_by, dataPartition);
const userEmail = await DESUserAssociation.convertSubIdToEmail(datasetOUT.created_by, dataPartition);
datasetOUT.created_by = userEmail;
}
......
......@@ -106,7 +106,8 @@ export class DatasetParser {
public static get(req: expRequest): [DatasetModel, boolean, boolean] {
return [this.createDatasetModelFromRequest(req),
req.query.seismicmeta === 'true', req.query['subid-to-email'] === 'true'];
req.query.seismicmeta === 'true', (req.query['subid-to-email'] !== undefined) ?
req.query['subid-to-email'] === 'true' : true];
}
......
......@@ -20,7 +20,7 @@ import { SubProjectModel } from '.';
import { Auth, AuthGroups, UserRoles } from '../../auth';
import { Config, JournalFactoryTenantClient, LoggerFactory, StorageFactory } from '../../cloud';
import { SeistoreFactory } from '../../cloud/seistore';
import { DESUtils, DESUserAssociation } from '../../dataecosystem';
import { DESUserAssociation, DESUtils } from '../../dataecosystem';
import { Error, Feature, FeatureFlags, Response, Utils } from '../../shared';
import { DatasetDAO, PaginationModel } from '../dataset';
import { TenantGroups, TenantModel } from '../tenant';
......@@ -216,8 +216,7 @@ export class SubProjectHandler {
if (FeatureFlags.isEnabled(Feature.CCM_INTERACTION) && convertSubIdToEmail) {
if (!Utils.isEmail(subproject.admin)) {
const dataPartition = DESUtils.getDataPartitionID(tenant.esd);
subproject.admin = await DESUserAssociation.convertSubIdToEmail
(req[Config.DE_FORWARD_APPKEY], subproject.admin, dataPartition);
subproject.admin = await DESUserAssociation.convertSubIdToEmail(subproject.admin, dataPartition);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment