diff --git a/cli/README.md b/cli/README.md deleted file mode 100644 index 469134152a..0000000000 --- a/cli/README.md +++ /dev/null @@ -1,102 +0,0 @@ -## Install -#### Windows -Use [Scoop](https://scoop.sh/) package manager - -``` -$ scoop bucket add org https://github.com/Infisical/scoop-infisical.git -$ scoop install infisical -$ infisical --version -``` - -To update: - -``` -$ scoop update infisical -``` - -#### Mac OS -Use [brew](https://brew.sh/) package manager - -``` -$ brew install infisical/get-cli/infisical -$ infisical --version -``` - -To update: - -``` -$ brew upgrade infisical -``` - -#### Linux -##### Debian/Ubuntu (package manager: apt) - -``` -Add Infisical apt repo -$ echo "deb [trusted=yes] https://apt.fury.io/infisical/ /" | tee -a /etc/apt/sources.list.d/infisical.list - -Add prerequisites -$ apt update && apt -y install ca-certificates sudo - -Install infisical cli -$ sudo apt update && apt install infisical - -To make sure the CLI has been installed, you may run this command. -$ infisical --version -``` - -We do not yet have repositores setup for APK, YUM and APT package managers. However, we have several binaries which can be downloaded manually for your Linux. Please vist the [release age](https://github.com/Infisical/infisical/releases) - -#### Install via bash and curl -This script will attempt to download the correct version of Infisical CLI and add it to your path. No package manager needed. - -``` -curl https://raw.githubusercontent.com/Infisical/infisical/main/scripts/install.sh | sh -``` - -## Local Usage -Once you have the CLI installed, using it is easy. - -#### Steps 1 -Create a project at https://infisical.com/ if you haven't already add your secrets to it. - -#### Step 2 -Login to the CLI by running the following command in your terminal - -``` -infisical login -``` - -#### Step 3 -After logging in, `CD` to the root of the project where you would like to inject your secrets into. Once you are in the root, run the following command in the terminal to link your Infisical project to your local project. - -``` -infisical init -``` - -#### Step 3 -To inject the secrets from the project you have selected into your application process, run the following command. - -``` -infisical run -- -``` - -Example: - -``` -infisical run -- npm run dev -``` - -## General production Usage -Once you have the binary installed in your production environment, injecting secrets is easy. - -#### Steps 1 -Get a Infisical Token for your project by visiting BLANK. Also note down the project ID for which you created the token for. - -#### Steps 2 -Ensure your application has the environment variable `INFISICAL_TOKEN` asigned to the token you received in step one. Then run - -``` -infisical run --projectId= -- -``` - diff --git a/cli/packages/cmd/login.go b/cli/packages/cmd/login.go index 7f68c5cd1b..86b74c6647 100644 --- a/cli/packages/cmd/login.go +++ b/cli/packages/cmd/login.go @@ -28,8 +28,9 @@ var loginCmd = &cobra.Command{ PreRun: toggleDebug, Run: func(cmd *cobra.Command, args []string) { hasUserLoggedInbefore, currentLoggedInUserEmail, err := util.IsUserLoggedIn() + if err != nil { - log.Debugln(err) + log.Debugln("Unable to get current logged in user.", err) } if hasUserLoggedInbefore { @@ -45,12 +46,6 @@ var loginCmd = &cobra.Command{ } } - if err != nil { - log.Errorln("Unable to get current logged in user.") - log.Debugln(err) - return - } - email, password, err := askForLoginCredentials() if err != nil { log.Errorln("Unable to parse email and password for authentication") @@ -160,6 +155,7 @@ func askForLoginCredentials() (email string, password string, err error) { } func getFreshUserCredentials(email string, password string) (*models.LoginTwoResponse, error) { + log.Debugln("getFreshUserCredentials:", "email", email, "password", password) httpClient := resty.New() httpClient.SetRetryCount(5) @@ -180,7 +176,7 @@ func getFreshUserCredentials(email string, password string) (*models.LoginTwoRes R(). SetBody(loginOneRequest). SetResult(&loginOneResponseResult). - Post(fmt.Sprintf("%v/%v", util.INFISICAL_URL, "login1")) + Post(fmt.Sprintf("%v/v1/auth/login1", util.INFISICAL_URL)) if err != nil { return nil, err @@ -216,7 +212,7 @@ func getFreshUserCredentials(email string, password string) (*models.LoginTwoRes R(). SetBody(LoginTwoRequest). SetResult(&loginTwoResponseResult). - Post(fmt.Sprintf("%v/%v", util.INFISICAL_URL, "login2")) + Post(fmt.Sprintf("%v/v1/auth/login2", util.INFISICAL_URL)) if err != nil { return nil, err diff --git a/cli/packages/cmd/root.go b/cli/packages/cmd/root.go index 0c6d31aa6c..1fa6e5abc0 100644 --- a/cli/packages/cmd/root.go +++ b/cli/packages/cmd/root.go @@ -30,5 +30,5 @@ func Execute() { func init() { rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") rootCmd.PersistentFlags().BoolVarP(&debugLogging, "debug", "d", false, "Enable verbose logging") - rootCmd.PersistentFlags().StringVar(&util.INFISICAL_URL, "domain", "http://localhost:4000", "Point the CLI to your own backend") + rootCmd.PersistentFlags().StringVar(&util.INFISICAL_URL, "domain", "https://app.infisical.com/api", "Point the CLI to your own backend") } diff --git a/cli/packages/util/common.go b/cli/packages/util/common.go index bfe61c3889..05b3497d25 100644 --- a/cli/packages/util/common.go +++ b/cli/packages/util/common.go @@ -12,7 +12,7 @@ const ( INFISICAL_SERVICE_TOKEN = "INFISICAL_SERVICE_TOKEN" ) -var INFISICAL_URL = "https://api.infisical.com" +var INFISICAL_URL = "https://app.infisical.com/api" func GetHomeDir() (string, error) { directory, err := os.UserHomeDir() diff --git a/cli/packages/util/credentials.go b/cli/packages/util/credentials.go index 984d5a0d12..c5396f6988 100644 --- a/cli/packages/util/credentials.go +++ b/cli/packages/util/credentials.go @@ -81,7 +81,7 @@ func IsUserLoggedIn() (hasUserLoggedIn bool, theUsersEmail string, err error) { response, err := httpClient. R(). - Post(fmt.Sprintf("%v/%v", INFISICAL_URL, "checkAuth")) + Post(fmt.Sprintf("%v/v1/auth/checkAuth", INFISICAL_URL)) if err != nil { return false, "", err diff --git a/cli/packages/util/secrets.go b/cli/packages/util/secrets.go index 2bff58b623..475640713e 100644 --- a/cli/packages/util/secrets.go +++ b/cli/packages/util/secrets.go @@ -31,7 +31,9 @@ func GetSecretsFromAPIUsingCurrentLoggedInUser(envName string, userCreds models. SetQueryParam("environment", envName). SetQueryParam("channel", "cli"). SetResult(&pullSecretsRequestResponse). - Get(fmt.Sprintf("%v/%v/%v", INFISICAL_URL, "secret", workspace.WorkspaceId)) // need to change workspace id + Get(fmt.Sprintf("%v/v1/secret/%v", INFISICAL_URL, workspace.WorkspaceId)) // need to change workspace id + + log.Debugln("Response from get secrets:", response) if err != nil { return nil, err @@ -116,7 +118,7 @@ func GetSecretsFromAPIUsingInfisicalToken(infisicalToken string, envName string, SetQueryParam("environment", envName). SetQueryParam("channel", "cli"). SetResult(&pullSecretsByInfisicalTokenResponse). - Get(fmt.Sprintf("%v/secret/%v/service-token", INFISICAL_URL, projectId)) + Get(fmt.Sprintf("%v/v1/secret/%v/service-token", INFISICAL_URL, projectId)) if err != nil { return nil, err @@ -191,7 +193,7 @@ func GetWorkSpacesFromAPI(userCreds models.UserCredentials) (workspaces []models response, err := httpClient. R(). SetResult(&getWorkSpacesResponse). - Get(fmt.Sprintf("%v/%v", INFISICAL_URL, "workspace")) + Get(fmt.Sprintf("%v/v1/workspace", INFISICAL_URL)) if err != nil { return nil, err