Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
when login expired, do not ask to override login
Maidul Islam871d80aad5e9
diff --git a/cli/packages/api/api.go b/cli/packages/api/api.goindex a414b03d37..7417a25940 100644--- a/cli/packages/api/api.go+++ b/cli/packages/api/api.go@@ -5,6 +5,7 @@ import ("github.com/Infisical/infisical-merge/packages/config""github.com/go-resty/resty/v2"+ log "github.com/sirupsen/logrus")const USER_AGENT = "cli"@@ -144,3 +145,24 @@ func CallGetAllWorkSpacesUserBelongsTo(httpClient *resty.Client) (GetWorkSpacesRreturn workSpacesResponse, nil}++func CallIsAuthenticated(httpClient *resty.Client) bool {+ var workSpacesResponse GetWorkSpacesResponse+ response, err := httpClient.+ R().+ SetResult(&workSpacesResponse).+ SetHeader("User-Agent", USER_AGENT).+ Post(fmt.Sprintf("%v/v1/auth/checkAuth", config.INFISICAL_URL))++ log.Debugln(fmt.Errorf("CallIsAuthenticated: Unsuccessful response: [response=%v]", response))++ if err != nil {+ return false+ }++ if response.IsError() {+ return false+ }++ return true+}diff --git a/cli/packages/cmd/login.go b/cli/packages/cmd/login.goindex c10f38fc43..74573c2265 100644--- a/cli/packages/cmd/login.go+++ b/cli/packages/cmd/login.go@@ -33,13 +33,13 @@ var loginCmd = &cobra.Command{PreRun: toggleDebug,Run: func(cmd *cobra.Command, args []string) {currentLoggedInUserDetails, err := util.GetCurrentLoggedInUserDetails()- if err != nil && strings.Contains(err.Error(), "The specified item could not be found in the keyring") { // if the key can't be found allow them to override+ if err != nil && (strings.Contains(err.Error(), "The specified item could not be found in the keyring") || strings.Contains(err.Error(), "unable to get key from Keyring")) { // if the key can't be found allow them to overridelog.Debug(err)} else if err != nil {util.HandleError(err)}- if currentLoggedInUserDetails.IsUserLoggedIn {+ if currentLoggedInUserDetails.IsUserLoggedIn && !currentLoggedInUserDetails.LoginExpired { // if you are logged in but not expiredshouldOverride, err := shouldOverrideLoginPrompt(currentLoggedInUserDetails.UserCredentials.Email)if err != nil {util.HandleError(err)diff --git a/cli/packages/util/constants.go b/cli/packages/util/constants.goindex 6c21dd7871..95b6ca228a 100644--- a/cli/packages/util/constants.go+++ b/cli/packages/util/constants.go@@ -11,5 +11,8 @@ const (KEYRING_SERVICE_NAME = "infisical"PERSONAL_SECRET_TYPE_NAME = "personal"SHARED_SECRET_TYPE_NAME = "shared"- CLI_VERSION = "v0.2.9" //+)++var (+ CLI_VERSION = "v0.2.9")diff --git a/cli/packages/util/credentials.go b/cli/packages/util/credentials.goindex 6410002c08..1766f04c77 100644--- a/cli/packages/util/credentials.go+++ b/cli/packages/util/credentials.go@@ -5,7 +5,7 @@ import ("fmt""github.com/99designs/keyring"- "github.com/Infisical/infisical-merge/packages/config"+ "github.com/Infisical/infisical-merge/packages/api""github.com/Infisical/infisical-merge/packages/models""github.com/go-resty/resty/v2")@@ -87,17 +87,10 @@ func GetCurrentLoggedInUserDetails() (LoggedInUserDetails, error) {SetAuthToken(userCreds.JTWToken).SetHeader("Accept", "application/json")- response, err := httpClient.- R().- Post(fmt.Sprintf("%v/v1/auth/checkAuth", config.INFISICAL_URL))-- if err != nil {- return LoggedInUserDetails{}, err- }-- if response.StatusCode() > 299 {+ isAuthenticated := api.CallIsAuthenticated(httpClient)+ if !isAuthenticated {return LoggedInUserDetails{- IsUserLoggedIn: true,+ IsUserLoggedIn: true, // was logged inLoginExpired: true,UserCredentials: userCreds,}, nil