Merge pull request #784 from akhilmhdh/fix/import-delete

fix: resolved secret import delete and include_import response control
This commit is contained in:
Maidul Islam
2023-07-24 11:47:02 -04:00
committed by GitHub
4 changed files with 14 additions and 12 deletions
@@ -30,7 +30,6 @@ export const createSecretImport = async (req: Request, res: Response) => {
if (doesImportExist) { if (doesImportExist) {
throw BadRequestError({ message: "Secret import already exist" }); throw BadRequestError({ message: "Secret import already exist" });
} }
importSecDoc.imports.push({ importSecDoc.imports.push({
environment: secretImport.environment, environment: secretImport.environment,
secretPath: secretImport.secretPath secretPath: secretImport.secretPath
@@ -830,7 +830,7 @@ export const getSecrets = async (req: Request, res: Response) => {
// TODO(akhilmhdh) - secret-imp change this to org type // TODO(akhilmhdh) - secret-imp change this to org type
let importedSecrets: any[] = []; let importedSecrets: any[] = [];
if (include_imports) { if (include_imports === "true") {
importedSecrets = await getAllImportedSecrets(workspaceId, environment, folderId as string); importedSecrets = await getAllImportedSecrets(workspaceId, environment, folderId as string);
} }
@@ -26,13 +26,16 @@ export const getSecretsRaw = async (req: Request, res: Response) => {
const includeImports = req.query.include_imports as string; const includeImports = req.query.include_imports as string;
// if the service token has single scope, it will get all secrets for that scope by default // if the service token has single scope, it will get all secrets for that scope by default
const serviceTokenDetails: IServiceTokenData = req?.serviceTokenData const serviceTokenDetails: IServiceTokenData = req?.serviceTokenData;
if (serviceTokenDetails) { if (serviceTokenDetails) {
if (serviceTokenDetails.scopes.length == 1 && !containsGlobPatterns(serviceTokenDetails.scopes[0].secretPath)) { if (
const scope = serviceTokenDetails.scopes[0] serviceTokenDetails.scopes.length == 1 &&
secretPath = scope.secretPath !containsGlobPatterns(serviceTokenDetails.scopes[0].secretPath)
environment = scope.environment ) {
workspaceId = serviceTokenDetails.workspace.toString() const scope = serviceTokenDetails.scopes[0];
secretPath = scope.secretPath;
environment = scope.environment;
workspaceId = serviceTokenDetails.workspace.toString();
} else { } else {
requireWorkspaceAuth({ requireWorkspaceAuth({
acceptedRoles: [ADMIN, MEMBER], acceptedRoles: [ADMIN, MEMBER],
@@ -41,7 +44,7 @@ export const getSecretsRaw = async (req: Request, res: Response) => {
requiredPermissions: [PERMISSION_READ_SECRETS], requiredPermissions: [PERMISSION_READ_SECRETS],
requireBlindIndicesEnabled: true, requireBlindIndicesEnabled: true,
requireE2EEOff: true requireE2EEOff: true
}) });
} }
} }
@@ -294,7 +297,7 @@ export const getSecrets = async (req: Request, res: Response) => {
authData: req.authData authData: req.authData
}); });
if (includeImports) { if (includeImports === "true") {
const folders = await Folder.findOne({ workspace: workspaceId, environment }); const folders = await Folder.findOne({ workspace: workspaceId, environment });
let folderId = "root"; let folderId = "root";
// if folder exist get it and replace folderid with new one // if folder exist get it and replace folderid with new one
+1 -1
View File
@@ -46,7 +46,7 @@ router.delete(
body("secretImportPath").isString().exists().trim(), body("secretImportPath").isString().exists().trim(),
body("secretImportEnv").isString().exists().trim(), body("secretImportEnv").isString().exists().trim(),
validateRequest, validateRequest,
secretImportController.updateSecretImport secretImportController.deleteSecretImport
); );
router.get( router.get(