From afd6a7736aac1679c94bee5d883327d2bad7918e Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Wed, 29 Nov 2023 09:57:45 -0500 Subject: [PATCH 1/2] add docs for folder cli command --- cli/packages/cmd/agent.go | 2 +- cli/packages/cmd/secrets.go | 4 +-- docs/cli/commands/secrets.mdx | 67 +++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/cli/packages/cmd/agent.go b/cli/packages/cmd/agent.go index 7af471a03..83986021d 100644 --- a/cli/packages/cmd/agent.go +++ b/cli/packages/cmd/agent.go @@ -260,7 +260,7 @@ var agentCmd = &cobra.Command{ infisical agent `, Use: "agent", - Short: "agent", + Short: "Used to launch a client daemon that streamlines authentication and secret retrieval processes in some environments", DisableFlagsInUseLine: true, Run: func(cmd *cobra.Command, args []string) { diff --git a/cli/packages/cmd/secrets.go b/cli/packages/cmd/secrets.go index 186776837..3aa808cf4 100644 --- a/cli/packages/cmd/secrets.go +++ b/cli/packages/cmd/secrets.go @@ -689,12 +689,12 @@ func init() { // Add createCmd flags here createCmd.Flags().StringP("path", "p", "/", "Path to where the folder should be created") - createCmd.Flags().StringP("name", "n", "", "Name of the folder to be created") + createCmd.Flags().StringP("name", "n", "", "Name of the folder to be created in selected `--path`") folderCmd.AddCommand(createCmd) // Add deleteCmd flags here deleteCmd.Flags().StringP("path", "p", "/", "Path to the folder to be deleted") - deleteCmd.Flags().StringP("name", "n", "", "Name of the folder to be deleted") + deleteCmd.Flags().StringP("name", "n", "", "Name of the folder to be deleted within selected `--path`") folderCmd.AddCommand(deleteCmd) secretsCmd.AddCommand(folderCmd) diff --git a/docs/cli/commands/secrets.mdx b/docs/cli/commands/secrets.mdx index b3fab541b..8e2183ad9 100644 --- a/docs/cli/commands/secrets.mdx +++ b/docs/cli/commands/secrets.mdx @@ -134,6 +134,73 @@ $ infisical secrets set STRIPE_API_KEY=sjdgwkeudyjwe DOMAIN=example.com HASH=jeb + + This command allows you to fetch, create and delete folders from within a path from a given project. + + ```bash + $ infisical secrets folders + ``` + + ### sub commands + + Used to fetch all folders within a path in a given project + ``` + infisical secrets folders get --path=/some/path/to/folder + ``` + #### Flags + + The path from where folders should be fetched from + + Default value: `/` + + + + Fetch folders using the Infisical service token + + Default value: `` + + + + + + Used to create a folder by name within a path. + ``` + infisical secrets folders create --path=/some/path/to/folder --name=folder-name + ``` + ### Flags + + Path to where the folder should be created + + Default value: `/` + + + + Name of the folder to be created in selected `--path` + + Default value: `` + + + + + Used to delete a folder by name within a path. + ``` + infisical secrets folders delete --path=/some/path/to/folder --name=folder-name + ``` + ### Flags + + Path to where the folder should be created + + Default value: `/` + + + + Name of the folder to be deleted within selected `--path` + + Default value: `` + + + + This command allows you to generate an example .env file from your secrets and with their associated comments and tags. This is useful when you would like to let others who work on the project but do not use Infisical become aware of the required environment variables and their intended values. From 4b41664fa4de97f9dbf279027d77548151709109 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Sat, 2 Dec 2023 13:28:32 -0500 Subject: [PATCH 2/2] chores: clean login --- backend/src/controllers/v2/authController.ts | 14 +++++--------- backend/src/routes/v2/auth.ts | 2 +- backend/src/validation/auth.ts | 7 ------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/backend/src/controllers/v2/authController.ts b/backend/src/controllers/v2/authController.ts index 01ebcdfa0..ce2fae34f 100644 --- a/backend/src/controllers/v2/authController.ts +++ b/backend/src/controllers/v2/authController.ts @@ -204,20 +204,16 @@ export const login2 = async (req: Request, res: Response) => { * @param res */ export const sendMfaToken = async (req: Request, res: Response) => { - const { - body: { email } - } = await validateRequest(reqValidator.SendMfaTokenV2, req); - const code = await TokenService.createToken({ type: TOKEN_EMAIL_MFA, - email + email: req.user.email }); // send MFA code [code] to [email] await sendMail({ template: "emailMfa.handlebars", subjectLine: "Infisical MFA code", - recipients: [email], + recipients: [req.user.email], substitutions: { code } @@ -236,17 +232,17 @@ export const sendMfaToken = async (req: Request, res: Response) => { */ export const verifyMfaToken = async (req: Request, res: Response) => { const { - body: { email, mfaToken } + body: { mfaToken } } = await validateRequest(reqValidator.VerifyMfaTokenV2, req); await TokenService.validateToken({ type: TOKEN_EMAIL_MFA, - email, + email: req.user.email, token: mfaToken }); const user = await User.findOne({ - email + email: req.user.email }).select( "+salt +verifier +encryptionVersion +protectedKey +protectedKeyIV +protectedKeyTag +publicKey +encryptedPrivateKey +iv +tag +devices" ); diff --git a/backend/src/routes/v2/auth.ts b/backend/src/routes/v2/auth.ts index c7aa6b066..c24324e3f 100644 --- a/backend/src/routes/v2/auth.ts +++ b/backend/src/routes/v2/auth.ts @@ -26,7 +26,7 @@ router.post( ); //remove above ones after depreciation -router.post("/mfa/send", authLimiter, authController.sendMfaToken); +router.post("/mfa/send", authLimiter, requireMfaAuth, authController.sendMfaToken); router.post("/mfa/verify", authLimiter, requireMfaAuth, authController.verifyMfaToken); diff --git a/backend/src/validation/auth.ts b/backend/src/validation/auth.ts index f32fc1197..071ad5e49 100644 --- a/backend/src/validation/auth.ts +++ b/backend/src/validation/auth.ts @@ -84,15 +84,8 @@ export const ResetPasswordV1 = z.object({ }) }); -export const SendMfaTokenV2 = z.object({ - body: z.object({ - email: z.string().email().trim() - }) -}); - export const VerifyMfaTokenV2 = z.object({ body: z.object({ - email: z.string().email().trim(), mfaToken: z.string().trim() }) });