From 544d37bbc47d857c3df350105a3d00f46b697f19 Mon Sep 17 00:00:00 2001 From: David Flanagan Date: Sun, 10 Dec 2023 16:13:38 +0000 Subject: [PATCH 1/4] fix: "Injecting..." status stirng can be omitted by log levels When using `infisical run`, I am often running another command that needs to be processed or consumed by another; such as: infisical run -- supabase status -o env The Injecting string was being printed directly to stdout and stopping such scripting from being successful, without further adding tail -n+2. This change defaults the output to the INFO logging level, which means the behaviour is the exact same for everything; however those who wish can omit this output with -l error|fatal --- cli/packages/cmd/run.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/packages/cmd/run.go b/cli/packages/cmd/run.go index ef83bc10c..8aa5306d9 100644 --- a/cli/packages/cmd/run.go +++ b/cli/packages/cmd/run.go @@ -204,7 +204,8 @@ func init() { func executeSingleCommandWithEnvs(args []string, secretsCount int, env []string) error { command := args[0] argsForCommand := args[1:] - color.Green("Injecting %v Infisical secrets into your application process", secretsCount) + + log.Info().Msgf(color.GreenString("Injecting %v Infisical secrets into your application process", secretsCount)) cmd := exec.Command(command, argsForCommand...) cmd.Stdin = os.Stdin @@ -232,7 +233,7 @@ func executeMultipleCommandWithEnvs(fullCommand string, secretsCount int, env [] cmd.Stderr = os.Stderr cmd.Env = env - color.Green("Injecting %v Infisical secrets into your application process", secretsCount) + log.Info().Msgf(color.GreenString("Injecting %v Infisical secrets into your application process", secretsCount)) log.Debug().Msgf("executing command: %s %s %s \n", shell[0], shell[1], fullCommand) return execCmd(cmd) From 1f97ac5192018f09fe70b04e87570c24ed750e21 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Mon, 11 Dec 2023 14:21:51 -0500 Subject: [PATCH 2/4] non-zero-max-ttl --- backend/src/models/identityAccessToken.ts | 4 ++-- backend/src/validation/auth.ts | 8 ++++++-- .../IdentityUniversalAuthForm.tsx | 18 +++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/backend/src/models/identityAccessToken.ts b/backend/src/models/identityAccessToken.ts index 7acdb2dbe..82b2e6778 100644 --- a/backend/src/models/identityAccessToken.ts +++ b/backend/src/models/identityAccessToken.ts @@ -53,13 +53,13 @@ const identityAccessTokenSchema = new Schema( accessTokenTTL: { // seconds // incremental lifetime type: Number, - default: 7200, + default: 2592000, // 30 days required: true }, accessTokenMaxTTL: { // seconds // max lifetime type: Number, - default: 7200, + default: 2592000, // 30 days required: true }, accessTokenTrustedIps: { diff --git a/backend/src/validation/auth.ts b/backend/src/validation/auth.ts index 84fea54b6..e723ba7d9 100644 --- a/backend/src/validation/auth.ts +++ b/backend/src/validation/auth.ts @@ -117,7 +117,9 @@ export const AddUniversalAuthToIdentityV1 = z.object({ .min(1) .default([{ ipAddress: "0.0.0.0/0" }]), accessTokenTTL: z.number().int().min(0).default(7200), - accessTokenMaxTTL: z.number().int().min(0).default(0), + accessTokenMaxTTL: z.number().int().refine(value => value !== 0, { + message: "accessTokenMaxTTL must have a non zero number", + }).default(2592000), // 30 days accessTokenNumUsesLimit: z.number().int().min(0).default(0) }) }); @@ -143,7 +145,9 @@ export const UpdateUniversalAuthToIdentityV1 = z.object({ .optional(), accessTokenTTL: z.number().int().min(0).optional(), accessTokenNumUsesLimit: z.number().int().min(0).optional(), - accessTokenMaxTTL: z.number().int().min(0).default(0), + accessTokenMaxTTL: z.number().int().refine(value => value !== 0, { + message: "accessTokenMaxTTL must have a non zero number", + }).default(2592000), }), }); diff --git a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx index a1d0a0bd2..6d327f9d4 100644 --- a/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx +++ b/frontend/src/views/Org/MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx @@ -88,8 +88,8 @@ export const IdentityUniversalAuthForm = ({ } = useForm({ resolver: yupResolver(schema), defaultValues: { - accessTokenTTL: "7200", - accessTokenMaxTTL: "0", + accessTokenTTL: "2592000", + accessTokenMaxTTL: "2592000", accessTokenNumUsesLimit: "0", clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" @@ -136,8 +136,8 @@ export const IdentityUniversalAuthForm = ({ }); } else { reset({ - accessTokenTTL: "7200", - accessTokenMaxTTL: "0", + accessTokenTTL: "2592000", + accessTokenMaxTTL: "2592000", accessTokenNumUsesLimit: "0", clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" @@ -211,7 +211,7 @@ export const IdentityUniversalAuthForm = ({
( ( From bb3d591f215f224dc13258eb013adab56f972ddd Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Mon, 11 Dec 2023 15:14:49 -0500 Subject: [PATCH 3/4] remove cli update notification delay --- cli/packages/util/check-for-update.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cli/packages/util/check-for-update.go b/cli/packages/util/check-for-update.go index 9921cef0d..ad07cb1d4 100644 --- a/cli/packages/util/check-for-update.go +++ b/cli/packages/util/check-for-update.go @@ -28,9 +28,9 @@ func CheckForUpdate() { return } - daysSinceRelease, _ := daysSinceDate(publishedDate) + // daysSinceRelease, _ := daysSinceDate(publishedDate) - if latestVersion != CLI_VERSION && daysSinceRelease > 2 { + if latestVersion != CLI_VERSION { yellow := color.New(color.FgYellow).SprintFunc() blue := color.New(color.FgCyan).SprintFunc() black := color.New(color.FgBlack).SprintFunc() @@ -151,15 +151,15 @@ func IsRunningInDocker() bool { return strings.Contains(string(cgroup), "docker") } -func daysSinceDate(dateString string) (int, error) { - layout := "2006-01-02T15:04:05Z" - parsedDate, err := time.Parse(layout, dateString) - if err != nil { - return 0, err - } +// func daysSinceDate(dateString string) (int, error) { +// layout := "2006-01-02T15:04:05Z" +// parsedDate, err := time.Parse(layout, dateString) +// if err != nil { +// return 0, err +// } - currentTime := time.Now() - difference := currentTime.Sub(parsedDate) - days := int(difference.Hours() / 24) - return days, nil -} +// currentTime := time.Now() +// difference := currentTime.Sub(parsedDate) +// days := int(difference.Hours() / 24) +// return days, nil +// } From f940f8b79db6262cbbcb7c1f711756b3551eb076 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Mon, 11 Dec 2023 16:52:47 -0500 Subject: [PATCH 4/4] remove unused methods in cli --- cli/packages/util/check-for-update.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cli/packages/util/check-for-update.go b/cli/packages/util/check-for-update.go index ad07cb1d4..f3aca2776 100644 --- a/cli/packages/util/check-for-update.go +++ b/cli/packages/util/check-for-update.go @@ -11,7 +11,6 @@ import ( "os/exec" "runtime" "strings" - "time" "github.com/fatih/color" "github.com/rs/zerolog/log" @@ -21,7 +20,7 @@ func CheckForUpdate() { if checkEnv := os.Getenv("INFISICAL_DISABLE_UPDATE_CHECK"); checkEnv != "" { return } - latestVersion, publishedDate, err := getLatestTag("Infisical", "infisical") + latestVersion, _, err := getLatestTag("Infisical", "infisical") if err != nil { log.Debug().Err(err) // do nothing and continue