mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 17:27:40 +00:00
Merge pull request #904 from Infisical/dashboard-get-secrets
Rewire dashboard to pull from v3/secrets with folderId support
This commit is contained in:
@@ -23,6 +23,7 @@ export const getSecretsRaw = async (req: Request, res: Response) => {
|
|||||||
let workspaceId = req.query.workspaceId as string;
|
let workspaceId = req.query.workspaceId as string;
|
||||||
let environment = req.query.environment as string;
|
let environment = req.query.environment as string;
|
||||||
let secretPath = req.query.secretPath as string;
|
let secretPath = req.query.secretPath as string;
|
||||||
|
const folderId = req.query.folderId as string | undefined;
|
||||||
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
|
||||||
@@ -47,6 +48,7 @@ export const getSecretsRaw = async (req: Request, res: Response) => {
|
|||||||
const secrets = await SecretService.getSecrets({
|
const secrets = await SecretService.getSecrets({
|
||||||
workspaceId: new Types.ObjectId(workspaceId),
|
workspaceId: new Types.ObjectId(workspaceId),
|
||||||
environment,
|
environment,
|
||||||
|
folderId,
|
||||||
secretPath,
|
secretPath,
|
||||||
authData: req.authData
|
authData: req.authData
|
||||||
});
|
});
|
||||||
@@ -284,11 +286,13 @@ export const getSecrets = async (req: Request, res: Response) => {
|
|||||||
const workspaceId = req.query.workspaceId as string;
|
const workspaceId = req.query.workspaceId as string;
|
||||||
const environment = req.query.environment as string;
|
const environment = req.query.environment as string;
|
||||||
const secretPath = req.query.secretPath as string;
|
const secretPath = req.query.secretPath as string;
|
||||||
|
const folderId = req.query.folderId as string | undefined;
|
||||||
const includeImports = req.query.include_imports as string;
|
const includeImports = req.query.include_imports as string;
|
||||||
|
|
||||||
const secrets = await SecretService.getSecrets({
|
const secrets = await SecretService.getSecrets({
|
||||||
workspaceId: new Types.ObjectId(workspaceId),
|
workspaceId: new Types.ObjectId(workspaceId),
|
||||||
environment,
|
environment,
|
||||||
|
folderId,
|
||||||
secretPath,
|
secretPath,
|
||||||
authData: req.authData
|
authData: req.authData
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -498,6 +498,7 @@ export const getSecretsHelper = async ({
|
|||||||
workspaceId,
|
workspaceId,
|
||||||
environment,
|
environment,
|
||||||
authData,
|
authData,
|
||||||
|
folderId,
|
||||||
secretPath = "/"
|
secretPath = "/"
|
||||||
}: GetSecretsParams) => {
|
}: GetSecretsParams) => {
|
||||||
let secrets: ISecret[] = [];
|
let secrets: ISecret[] = [];
|
||||||
@@ -507,7 +508,10 @@ export const getSecretsHelper = async ({
|
|||||||
throw UnauthorizedRequestError({ message: "Folder Permission Denied" });
|
throw UnauthorizedRequestError({ message: "Folder Permission Denied" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const folderId = await getFolderIdFromServiceToken(workspaceId, environment, secretPath);
|
|
||||||
|
if (!folderId) {
|
||||||
|
folderId = await getFolderIdFromServiceToken(workspaceId, environment, secretPath);
|
||||||
|
}
|
||||||
|
|
||||||
// get personal secrets first
|
// get personal secrets first
|
||||||
secrets = await Secret.find({
|
secrets = await Secret.find({
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export interface CreateSecretParams {
|
|||||||
export interface GetSecretsParams {
|
export interface GetSecretsParams {
|
||||||
workspaceId: Types.ObjectId;
|
workspaceId: Types.ObjectId;
|
||||||
environment: string;
|
environment: string;
|
||||||
|
folderId?: string;
|
||||||
secretPath: string;
|
secretPath: string;
|
||||||
authData: AuthData;
|
authData: AuthData;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ router.get(
|
|||||||
"/raw",
|
"/raw",
|
||||||
query("workspaceId").optional().isString().trim(),
|
query("workspaceId").optional().isString().trim(),
|
||||||
query("environment").optional().isString().trim(),
|
query("environment").optional().isString().trim(),
|
||||||
|
query("folderId").optional().isString().trim(),
|
||||||
query("secretPath").default("/").isString().trim(),
|
query("secretPath").default("/").isString().trim(),
|
||||||
query("include_imports").optional().isBoolean().default(false),
|
query("include_imports").optional().isBoolean().default(false),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
@@ -144,6 +145,7 @@ router.get(
|
|||||||
"/",
|
"/",
|
||||||
query("workspaceId").exists().isString().trim(),
|
query("workspaceId").exists().isString().trim(),
|
||||||
query("environment").exists().isString().trim(),
|
query("environment").exists().isString().trim(),
|
||||||
|
query("folderId").optional().isString().trim(),
|
||||||
query("secretPath").default("/").isString().trim(),
|
query("secretPath").default("/").isString().trim(),
|
||||||
validateRequest,
|
validateRequest,
|
||||||
requireAuth({
|
requireAuth({
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const fetchProjectEncryptedSecrets = async (
|
|||||||
folderId?: string,
|
folderId?: string,
|
||||||
secretPath?: string
|
secretPath?: string
|
||||||
) => {
|
) => {
|
||||||
const { data } = await apiRequest.get<{ secrets: EncryptedSecret[] }>("/api/v2/secrets", {
|
const { data } = await apiRequest.get<{ secrets: EncryptedSecret[] }>("/api/v3/secrets", {
|
||||||
params: {
|
params: {
|
||||||
environment: env,
|
environment: env,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
|
|||||||
Reference in New Issue
Block a user