From 3ac98ba326ee01414dafe6acd52c29ae266c886d Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Thu, 16 Mar 2023 15:47:24 +0700 Subject: [PATCH] Improve SDK, quickstart, token, features docs --- docker-compose.dev.yml | 5 +- docs/getting-started/dashboard/token.mdx | 19 ++-- docs/getting-started/features.mdx | 28 ++--- docs/getting-started/introduction.mdx | 16 ++- docs/getting-started/quickstart.mdx | 112 +++++++++++++++---- docs/mint.json | 18 ++- docs/sdks/{overview => languages}/go.mdx | 0 docs/sdks/{overview => languages}/java.mdx | 0 docs/sdks/{overview => languages}/node.mdx | 0 docs/sdks/{overview => languages}/python.mdx | 0 docs/sdks/{overview => languages}/ruby.mdx | 0 docs/sdks/{overview => languages}/rust.mdx | 0 docs/sdks/overview.mdx | 18 +++ 13 files changed, 150 insertions(+), 66 deletions(-) rename docs/sdks/{overview => languages}/go.mdx (100%) rename docs/sdks/{overview => languages}/java.mdx (100%) rename docs/sdks/{overview => languages}/node.mdx (100%) rename docs/sdks/{overview => languages}/python.mdx (100%) rename docs/sdks/{overview => languages}/ruby.mdx (100%) rename docs/sdks/{overview => languages}/rust.mdx (100%) create mode 100644 docs/sdks/overview.mdx diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 007884694a..7e904cd14b 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -34,6 +34,7 @@ services: env_file: .env environment: - NODE_ENV=development + - MONGO_URL=mongodb://root:example@mongo:27017/?authSource=admin networks: - infisical-dev @@ -65,8 +66,8 @@ services: restart: always env_file: .env environment: - - MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME} - - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD} + - MONGO_INITDB_ROOT_USERNAME=root + - MONGO_INITDB_ROOT_PASSWORD=example volumes: - mongo-data:/data/db networks: diff --git a/docs/getting-started/dashboard/token.mdx b/docs/getting-started/dashboard/token.mdx index 0caaa81d73..caeb1641d8 100644 --- a/docs/getting-started/dashboard/token.mdx +++ b/docs/getting-started/dashboard/token.mdx @@ -1,26 +1,21 @@ --- title: "Infisical Token" -description: "Use Infisical service token as one of the authentication methods." +description: "Use the Infisical Token as one of the authentication methods." --- -An Infisical Token is needed to authenticate the CLI when there isn't an easy way to input your login credentials. +An Infisical Token is useful for: -It's useful for your CI/CD environments and integrations such as [Docker](/integrations/platforms/docker) and [Docker Compose](/integrations/platforms/docker-compose). +- Authenticating the [Infisical CLI](/cli/overview) when there isn't an easy way to input your login credentials. +- Granting the [Infisical SDKs](/sdks/overview) access to secrets scoped to a project and environment. -To generate the the token, head over to your project settings as shown below. +It's also useful for CI/CD environments and integrations such as [Docker](/integrations/platforms/docker) and [Docker Compose](/integrations/platforms/docker-compose). +To generate the the token, head over to your project settings as shown below. ![token add](../../images/project-token-add.png) ## Feeding Infisical Token to the CLI -The Infisical CLI checks for the presence of an environment variable called `INFISICAL_TOKEN`. +The Infisical CLI checks for the presence of an environment variable called `INFISICAL_TOKEN`. If it detects this variable in the terminal where it is being run, it will use it to authenticate and retrieve the environment variables that the token is authorized to access. This allows you to use the CLI in environments where you are unable to run the `infisical login` command. - - - The token grants read-only access to a particular environment and project for - a specified amount of time. Once the token is expired, the CLI using it will no longer be able to make - requests with it. - - diff --git a/docs/getting-started/features.mdx b/docs/getting-started/features.mdx index 5b163806b7..9eb1d4faf5 100644 --- a/docs/getting-started/features.mdx +++ b/docs/getting-started/features.mdx @@ -1,10 +1,8 @@ --- title: "Features" -description: "A list of features that Infisical has to offer." +description: "A non-exhaustive list of features that Infisical has to offer." --- -This is a non-exhaustive list of features that Infisical offers: - ## Platform - Provision members access to organizations and projects. @@ -16,29 +14,17 @@ This is a non-exhaustive list of features that Infisical offers: ## CLI -The CLI is used to inject environment variables into applications and infrastructure. +The [CLI](/cli/overview) is used to inject environment variables into applications and infrastructure. - Inject environment variables. - Inject environment variables into containers via service tokens for Docker. +## SDKs + +[SDKs](/sdks/overview) enable apps to fetch back secrets using an [Infisical Token](/getting-started/dashboard/token) scoped to a project and environment. + ## Roadmap -We're building the future of secret management, one that's comprehensive and accessible to all. Some high-level features we have in mind: - -| Feature | Status | -| ------------------------------------- | ----------- | -| Account recovery: Backup key | Done | -| 2FA | Done | -| Read/write access controls | Done | -| Comparing secrets across environments | Done | -| Integrations | Ongoing | -| More hosting options | Ongoing | -| 1-Click Deploys | Ongoing | -| Access logs | Ongoing | -| Account recovery: Member-assisted | Coming soon | -| Slack & MS teams integrations | Coming soon | -| Version control for secrets | Coming soon | -| Restricted IPs | Coming soon | -| Secret rotation | Coming soon | +We're building the future of secret management, one that's comprehensive and accessible to all. Check out our [roadmap](https://www.notion.so/infisical/be2d2585a6694e40889b03aef96ea36b?v=5b19a8127d1a4060b54769567a8785fa). Interested in contributing? Check out the [guide](/contributing/overview). diff --git a/docs/getting-started/introduction.mdx b/docs/getting-started/introduction.mdx index ff8b72c4d7..38dcffe3ac 100644 --- a/docs/getting-started/introduction.mdx +++ b/docs/getting-started/introduction.mdx @@ -19,6 +19,9 @@ Start syncing environment variables with [Infisical Cloud](https://app.infisical Install the CLI to inject secrets into apps and infra. + + Install an SDK into your app to fetch secrets. + - - - Our team is happy to help you get started with Infisical. If you have any questions or want to learn how you can leverage Infisical within your infrastructure, **[set up a 1-on-1 with an Infisical engineer](https://cal.com/maidul/15min)**. + + Our team is happy to help you get started with Infisical. If you have any + questions or want to learn how you can leverage Infisical within your + infrastructure, **[set up a 1-on-1 with an Infisical + engineer](https://cal.com/maidul/15min)**. diff --git a/docs/getting-started/quickstart.mdx b/docs/getting-started/quickstart.mdx index e3acd440d0..256ae8f853 100644 --- a/docs/getting-started/quickstart.mdx +++ b/docs/getting-started/quickstart.mdx @@ -3,9 +3,7 @@ title: "Quickstart" description: "Start managing your developer secrets and configs with Infisical in 10 minutes." --- -This example demonstrates how to store and inject environment variables from [Infisical Cloud](https://app.infisical.com) into your application. - -Note that the Infisical CLI is platform-agnostic and can inject environment variables across many tech stacks and frameworks. +These examples demonstrate how to store and fetch environment variables from [Infisical Cloud](https://app.infisical.com) into your application. ## Set up Infisical Cloud @@ -15,30 +13,100 @@ Note that the Infisical CLI is platform-agnostic and can inject environment vari ![project quickstart](../images/project-quickstart.png) -## Set up the CLI +## Fetch Secrets for Your App + + + + + The Infisical CLI is platform-agnostic and enables you to inject environment variables into your app across many tech stacks and frameworks. + + ### Set up the CLI + + 1. Follow the instructions to [install our platform-agnostic CLI](/cli/overview). + + 2. Initialize Infisical for your project. + + ```bash + # move to your project + cd /path/to/project + + # initialize infisical + infisical init + ``` + + ### Start your app with environment variables injected + + ```bash + # inject environment variables into app + infisical run -- [your application start command] + ``` + + Your app should now be running with the environment variables injected. + + Check out our [integrations](/integrations/overview) for injecting environment variables into frameworks and platforms like Docker. + + + + [Infisical SDKs](/sdks/overview) let your app fetch back secrets using an [Infisical Token](/getting-started/dashboard/token) that is scoped to a project and environment in Infisical. In this example, we demonstrate how to use the [Node SDK](/sdks/languages/node). + + ### Obtain an [Infisical Token](/getting-started/dashboard/token) + + Head to your project settings to create a token scoped to the project and environment you wish to fetch secrets from. + + ![token add](../images/project-token-add.png) + + ### Install the SDK + + ```bash + npm install infisical-node --save + ``` + + ### Initialize the Infisical client + + ```js + await infisical.connect({ + token: "your_infisical_token", + }); + ``` + + ### Get a value + + ```js + const value = infisical.get("SOME_KEY"); + ``` + + ### Example with Express -1. Follow the instructions to [install the CLI](/cli/overview). + ```js + const express = require("express"); + const port = 3000; + const infisical = require("infisical-node"); -2. Initialize Infisical for your project. + const main = async () => { + await infisical.connect({ + token: "st.xxx.xxx", + }); -```bash -# move to your project -cd /path/to/project + // your application logic -# initialize infisical -infisical init -``` + app.get("/", (req, res) => { + res.send(`Howdy, ${infisical.get("NAME")}!`); + }); -## Start your app with environment variables injected + app.listen(port, async () => { + console.log(`App listening on port ${port}`); + }); + }; + ``` -```bash -# inject environment variables into app -infisical run -- [your application start command] -``` + + We do not recommend hardcoding your [Infisical + Token](/getting-started/dashboard/token). Setting it as an environment + variable would be best. - - Check out our [integrations](/integrations/overview) for injecting environment - variables into frameworks and platforms like Docker. - + + + Check out our [SDKs](/sdks/overview) for other language SDKs. -Your app should be running with the environment variables injected. + + diff --git a/docs/mint.json b/docs/mint.json index efd6697810..e257ea0c5e 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -191,15 +191,21 @@ "self-hosting/configuration/email" ] }, + { + "group": "Overview", + "pages": [ + "sdks/overview" + ] + }, { "group": "SDKs", "pages": [ - "sdks/overview/node", - "sdks/overview/python", - "sdks/overview/java", - "sdks/overview/ruby", - "sdks/overview/go", - "sdks/overview/rust" + "sdks/languages/node", + "sdks/languages/python", + "sdks/languages/java", + "sdks/languages/ruby", + "sdks/languages/go", + "sdks/languages/rust" ] }, { diff --git a/docs/sdks/overview/go.mdx b/docs/sdks/languages/go.mdx similarity index 100% rename from docs/sdks/overview/go.mdx rename to docs/sdks/languages/go.mdx diff --git a/docs/sdks/overview/java.mdx b/docs/sdks/languages/java.mdx similarity index 100% rename from docs/sdks/overview/java.mdx rename to docs/sdks/languages/java.mdx diff --git a/docs/sdks/overview/node.mdx b/docs/sdks/languages/node.mdx similarity index 100% rename from docs/sdks/overview/node.mdx rename to docs/sdks/languages/node.mdx diff --git a/docs/sdks/overview/python.mdx b/docs/sdks/languages/python.mdx similarity index 100% rename from docs/sdks/overview/python.mdx rename to docs/sdks/languages/python.mdx diff --git a/docs/sdks/overview/ruby.mdx b/docs/sdks/languages/ruby.mdx similarity index 100% rename from docs/sdks/overview/ruby.mdx rename to docs/sdks/languages/ruby.mdx diff --git a/docs/sdks/overview/rust.mdx b/docs/sdks/languages/rust.mdx similarity index 100% rename from docs/sdks/overview/rust.mdx rename to docs/sdks/languages/rust.mdx diff --git a/docs/sdks/overview.mdx b/docs/sdks/overview.mdx new file mode 100644 index 0000000000..fd27ad9026 --- /dev/null +++ b/docs/sdks/overview.mdx @@ -0,0 +1,18 @@ +--- +title: "Overview" +description: "How to use Infisical SDKs to fetch back secrets for your app" +--- + +Infisical SDKs provide the easiest way for your app to fetch back secrets using an [Infisical Token](/getting-started/dashboard/token) and has a few benefits: + +- Local development: Replace 10s of environment variables in your `.env` file with 1 environment variable (the [Infisical Token](/getting-started/dashboard/token)). +- Production: Fetch secrets back to any cloud regardless of if an integration exists between Infisical and the cloud platform. + +We currently only have the [Node SDK](/sdks/languages/node) available but more language SDKs are coming out soon: + +- [Node](/sdks/languages/node) +- [Python](/sdks/languages/python) +- [Java](/sdks/languages/java) +- [Ruby](/sdks/languages/ruby) +- [Go](/sdks/languages/go) +- [Rust](/sdks/languages/rust)