Skip to content

Commit

Permalink
add back .populate(tags) to secrets GET via service token
Browse files Browse the repository at this point in the history
  • Loading branch information
maidul98 committed Apr 10, 2023
1 parent 576381c commit 689ac6a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions backend/src/controllers/v2/secretsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,9 @@ export const getSecrets = async (req: Request, res: Response) => {
return tag ? tag.id : null;
});
}

let secrets: ISecret[] = [];

if (req.user) {
// case: client authorization is via JWT

Expand All @@ -578,12 +578,12 @@ export const getSecrets = async (req: Request, res: Response) => {
let secretQuery: any;
if (tagNamesList != undefined && tagNamesList.length != 0) {
const workspaceFromDB = await Tag.find({ workspace: workspaceId })

const tagIds = _.map(tagNamesList, (tagName) => {
const tag = _.find(workspaceFromDB, { slug: tagName });
return tag ? tag.id : null;
});

secretQuery = {
workspace: workspaceId,
environment,
Expand All @@ -608,15 +608,15 @@ export const getSecrets = async (req: Request, res: Response) => {

if (hasWriteOnlyAccess) {
// (i.e. you don't get values to decrypt since you can only write)
secrets = await Secret.find(secretQuery).select("secretKeyCiphertext secretKeyIV secretKeyTag")
secrets = await Secret.find(secretQuery).select("secretKeyCiphertext secretKeyIV secretKeyTag").populate("tags")
} else {
secrets = await Secret.find(secretQuery).populate("tags")
}
}

if (req.serviceAccount || req.serviceTokenData) {
// case: client authorization is either via service account or service token

secrets = await Secret.find({
workspace: new Types.ObjectId(workspaceId),
environment,
Expand All @@ -625,7 +625,7 @@ export const getSecrets = async (req: Request, res: Response) => {
},
...(tagIds.length > 0 ? { tags: { $in: tagIds } } : {}),
type: SECRET_SHARED
});
}).populate("tags");
}

const channel = getChannelFromUserAgent(req.headers['user-agent'])
Expand All @@ -638,7 +638,7 @@ export const getSecrets = async (req: Request, res: Response) => {
workspaceId: new Types.ObjectId(workspaceId as string),
secretIds: secrets.map((n: any) => n._id)
});

readAction && await EELogService.createLog({
userId: req.user?._id,
serviceAccountId: req.serviceAccount?._id,
Expand Down Expand Up @@ -952,7 +952,7 @@ export const deleteSecrets = async (req: Request, res: Response) => {
}
}
*/

return res.status(200).send({
message: 'delete secrets!!'
});
Expand Down

1 comment on commit 689ac6a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for backend

St.
Category Percentage Covered / Total
🟢 Statements 90.63% 87/96
🔴 Branches 25% 2/8
🔴 Functions 50% 3/6
🟢 Lines 92.47% 86/93

Test suite run success

24 tests passing in 2 suites.

Report generated by 🧪jest coverage report action from 689ac6a

Please sign in to comment.