Merge branch 'main' into snyk-upgrade-9829915033f54fef09ffef896e2c5908

This commit is contained in:
Maidul Islam
2023-04-27 09:57:49 -04:00
committed by GitHub
10 changed files with 1015 additions and 800 deletions

1500
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"dependencies": { "dependencies": {
"@aws-sdk/client-secrets-manager": "^3.303.0", "@aws-sdk/client-secrets-manager": "^3.306.0",
"@godaddy/terminus": "^4.11.2", "@godaddy/terminus": "^4.11.2",
"@octokit/rest": "^19.0.5", "@octokit/rest": "^19.0.5",
"@sentry/node": "^7.41.0", "@sentry/node": "^7.41.0",
@@ -10,7 +10,7 @@
"argon2": "^0.30.3", "argon2": "^0.30.3",
"await-to-js": "^3.0.0", "await-to-js": "^3.0.0",
"aws-sdk": "^2.1338.0", "aws-sdk": "^2.1338.0",
"axios": "^1.1.3", "axios": "^1.3.5",
"axios-retry": "^3.4.0", "axios-retry": "^3.4.0",
"bcrypt": "^5.1.0", "bcrypt": "^5.1.0",
"bigint-conversion": "^2.2.2", "bigint-conversion": "^2.2.2",

View File

@@ -49,6 +49,8 @@ These examples demonstrate how to store and fetch environment variables from [In
<Tab title="SDK"> <Tab title="SDK">
[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). [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).
Using Python? We have a [Python SDK](/sdks/languages/python) as well.
### Obtain an [Infisical Token](/getting-started/dashboard/token) ### 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. Head to your project settings to create a token scoped to the project and environment you wish to fetch secrets from.

View File

@@ -1,5 +1,6 @@
--- ---
title: "Go" title: "Go"
icon: "golang"
--- ---
Coming soon. Coming soon.

View File

@@ -1,5 +1,6 @@
--- ---
title: "Java" title: "Java"
icon: "java"
--- ---
Coming soon. Coming soon.

View File

@@ -1,5 +1,6 @@
--- ---
title: "Node" title: "Node"
icon: "node"
--- ---
If you're working with Node.js, the official [infisical-node](https://github.com/Infisical/infisical-node) package is the easiest way to fetch and work with secrets for your application. If you're working with Node.js, the official [infisical-node](https://github.com/Infisical/infisical-node) package is the easiest way to fetch and work with secrets for your application.
@@ -7,8 +8,8 @@ If you're working with Node.js, the official [infisical-node](https://github.com
## Basic Usage ## Basic Usage
```js ```js
import InfisicalClient from "infisical-node";
import express from "express"; import express from "express";
import InfisicalClient from "infisical-node";
const app = express(); const app = express();
const PORT = 3000; const PORT = 3000;
@@ -40,8 +41,8 @@ This example demonstrates how to use the Infisical SDK with an Express applicati
Run `npm` to add `infisical-node` to your project. Run `npm` to add `infisical-node` to your project.
```bash ```console
npm install infisical-node --save $ npm install infisical-node --save
``` ```
## Configuration ## Configuration
@@ -75,39 +76,54 @@ Import the SDK and create a client instance with your Infisical token.
</Tabs> </Tabs>
<ResponseField name="options" type="object"> ### Parameters
<ParamField query="options" type="object">
<Expandable title="properties"> <Expandable title="properties">
<ResponseField name="token" type="string"> <ParamField query="token" type="string" optional>
An [Infisical Token](/getting-started/dashboard/token) scoped to a project An [Infisical Token](/getting-started/dashboard/token) scoped to a project
and environment and environment
</ResponseField> </ParamField>
<ResponseField <ParamField
name="siteURL" query="siteURL"
type="string" type="string"
default="https://app.infisical.com" default="https://app.infisical.com"
optional
> >
Your self-hosted absolute site URL including the protocol (e.g. Your self-hosted absolute site URL including the protocol (e.g.
`https://app.infisical.com`) `https://app.infisical.com`)
</ResponseField> </ParamField>
<ResponseField name="cacheTTL" type="number" default="300"> <ParamField query="cacheTTL" type="number" default="300" optional>
Time-to-live (in seconds) for refreshing cached secrets. Default: `300`. Time-to-live (in seconds) for refreshing cached secrets. Default: `300`.
</ResponseField> </ParamField>
<ResponseField name="debug" type="boolean" default="false"> <ParamField query="debug" type="boolean" default="false" optional>
Whether or not debug mode is on Whether or not debug mode is on
</ResponseField> </ParamField>
</Expandable> </Expandable>
</ResponseField> </ParamField>
## Caching ## Caching
The SDK caches every secret and updates it periodically based on the provided `cacheTTL`. For example, if `cacheTTL` of `300` is provided, then a secret will be refetched 5 minutes after the first fetch; if the fetch fails, the cached secret is returned. The SDK caches every secret and updates it periodically based on the provided `cacheTTL`. For example, if `cacheTTL` of `300` is provided, then a secret will be refetched 5 minutes after the first fetch; if the fetch fails, the cached secret is returned.
<Tip>
For optimal performance, we recommend creating a single instance of the Infisical client and exporting it to be used across your entire app to take advantage of caching benefits.
</Tip>
## Working with Secrets ## Working with Secrets
### infisical.getSecret(secretName, options) ### client.getAllSecrets()
```js ```js
const secret = await infisical.getSecret("API_KEY"); const secrets = await client.getAllSecrets();
```
Retrieve all secrets within the Infisical project and environment that client is connected to
### client.getSecret(secretName, options)
```js
const secret = await client.getSecret("API_KEY");
const value = secret.secretValue; // get its value const value = secret.secretValue; // get its value
``` ```
@@ -115,79 +131,82 @@ Retrieve a secret from Infisical.
By default, `getSecret()` fetches and returns a personal secret. If not found, it returns a shared secret, or tries to retrieve the value from `process.env`. If a secret is fetched, `getSecret()` caches it to reduce excessive calls and re-fetches periodically based on the `cacheTTL` option (default is `300` seconds) when initializing the client — for more information, see the caching section. By default, `getSecret()` fetches and returns a personal secret. If not found, it returns a shared secret, or tries to retrieve the value from `process.env`. If a secret is fetched, `getSecret()` caches it to reduce excessive calls and re-fetches periodically based on the `cacheTTL` option (default is `300` seconds) when initializing the client — for more information, see the caching section.
### Parameters
<ResponseField name="secretName" type="string" required> <ParamField query="secretName" type="string" required>
The key of the secret to retrieve The key of the secret to retrieve
</ResponseField> </ParamField>
<ResponseField name="options" type="object"> <ParamField query="options" type="object" optional>
<Expandable title="properties"> <Expandable title="properties">
<ResponseField name="type" type="string"> <ParamField query="type" type="string" default="personal" optional>
"personal" (default) or "shared". The type of the secret. Valid options are "shared" or "personal"
</ResponseField> </ParamField>
</Expandable> </Expandable>
</ResponseField> </ParamField>
### infisical.createSecret(secretName, secretValue, options) ### client.createSecret(secretName, secretValue, options)
```js ```js
const newApiKey = await infisical.createSecret("API_KEY", "FOO"); const newApiKey = await client.createSecret("API_KEY", "FOO");
``` ```
Create a new secret in Infisical. Create a new secret in Infisical.
<ResponseField name="secretName" type="string" required> <ParamField query="secretName" type="string" required>
The key of the secret to create The key of the secret to create
</ResponseField> </ParamField>
<ResponseField name="secretName" type="string" required> <ParamField query="secretName" type="string" required>
The value of the secret to create The value of the secret to create
</ResponseField> </ParamField>
<ResponseField name="options" type="object"> <ParamField query="options" type="object" default="object" optional>
<Expandable title="properties"> <Expandable title="properties">
<ResponseField name="type" type="string"> <ParamField query="type" type="string" default="shared" optional>
"shared" (default) or "personal". A personal secret can only be created if a shared secret with the same name exists. The type of the secret. Valid options are "shared" or "personal". A personal secret can only be created if a shared secret with the same name exists.
</ResponseField> </ParamField>
</Expandable> </Expandable>
</ResponseField> </ParamField>
### infisical.updateSecret(secretName, secretValue, options) ### client.updateSecret(secretName, secretValue, options)
```js ```js
const updatedApiKey = await infisical.updateSecret("API_KEY", "BAR"); const updatedApiKey = await client.updateSecret("API_KEY", "BAR");
``` ```
Update an existing secret in Infisical. Update an existing secret in Infisical.
<ResponseField name="secretName" type="string" required> ### Parameters
The key of the secret to update
</ResponseField>
<ResponseField name="secretName" type="string" required>
The new value of the secret
</ResponseField>
<ResponseField name="options" type="object">
<Expandable title="properties">
<ResponseField name="type" type="string">
"shared" (default) or "personal".
</ResponseField>
</Expandable>
</ResponseField>
### infisical.deleteSecret(secretName, options) <ParamField query="secretName" type="string" required>
The key of the secret to update
</ParamField>
<ParamField query="secretName" type="string" required>
The new value of the secret
</ParamField>
<ParamField query="options" type="object" default="object" optional>
<Expandable title="properties">
<ParamField query="type" type="string" default="shared" optional>
The type of the secret. Valid options are "shared" or "personal"
</ParamField>
</Expandable>
</ParamField>
### client.deleteSecret(secretName, options)
```js ```js
const deletedSecret = await infisical.deleteSecret("API_KEY"); const deletedSecret = await client.deleteSecret("API_KEY");
``` ```
Delete a secret in Infisical. Delete a secret in Infisical.
<ResponseField name="secretName" type="string" required> <ParamField query="secretName" type="string" required>
The key of the secret to delete The key of the secret to delete
</ResponseField> </ParamField>
<ResponseField name="options" type="object"> <ParamField query="options" type="object" default="object" optional>
<Expandable title="properties"> <Expandable title="properties">
<ResponseField name="type" type="string"> <ParamField query="type" type="string" default="shared" optional>
"shared" (default) or "personal". Note that deleting a shared secret also deletes all associated personal secrets. The type of the secret. Valid options are "shared" or "personal". Note that deleting a shared secret also deletes all associated personal secrets.
</ResponseField> </ParamField>
</Expandable> </Expandable>
</ResponseField> </ParamField>

View File

@@ -1,8 +1,169 @@
--- ---
title: "Python" title: "Python"
icon: "python"
--- ---
Coming soon. If you're working with Python, the official [infisical-python](https://github.com/Infisical/infisical-python) package is the easiest way to fetch and work with secrets for your application.
## Basic Usage
```py
from flask import Flask
from infisical import InfisicalClient
app = Flask(__name__)
client = InfisicalClient(token="your_infisical_token")
@app.route("/")
def hello_world():
# access value
name = client.get_secret("NAME")
return f"Hello! My name is: {name.secret_value}"
```
This example demonstrates how to use the Infisical Python SDK with a Flask application. The application retrieves a secret named "NAME" and responds to requests with a greeting that includes the secret value.
<Warning>
We do not recommend hardcoding your [Infisical
Token](/getting-started/dashboard/token). Setting it as an environment
variable would be best.
</Warning>
## Installation
Run `pip` to add `infisical-python` to your project
```console
$ pip install infisical
```
Note: You need Python 3.7+.
## Configuration
Import the SDK and create a client instance with your Infisical token.
```py
from infisical import InfisicalClient
client = InfisicalClient(token="your_infisical_token")
```
### Parameters
<ParamField query="token" type="string" optional>
An [Infisical Token](/getting-started/dashboard/token) scoped to a project
and environment
</ParamField>
<ParamField
query="site_url"
type="string"
default="https://app.infisical.com"
optional
>
Your self-hosted absolute site URL including the protocol (e.g.
`https://app.infisical.com`)
</ParamField>
<ParamField query="cache_ttl" type="number" default="300" optional>
Time-to-live (in seconds) for refreshing cached secrets. Default: `300`.
</ParamField>
<ParamField query="debug" type="boolean" default="false" optional>
Whether or not debug mode is on
</ParamField>
## Caching
The SDK caches every secret and updates it periodically based on the provided `cache_ttl`. For example, if `cache_ttl` of `300` is provided, then a secret will be refetched 5 minutes after the first fetch; if the fetch fails, the cached secret is returned.
<Tip>
For optimal performance, we recommend creating a single instance of the Infisical client and exporting it to be used across your entire app to take advantage of caching benefits.
</Tip>
## Working with Secrets
### client.get_all_secrets()
```py
secrets = client.get_all_secrets()
```
Retrieve all secrets within the Infisical project and environment that client is connected to
### client.get_secret(secret_name, options)
```py
secret = client.get_secret("API_KEY")
value = secret.secret_value # get its value
```
By default, `get_secret()` fetches and returns a personal secret. If not found, it returns a shared secret, or tries to retrieve the value from `os.environ`. If a secret is fetched, `get_secret()` caches it to reduce excessive calls and re-fetches periodically based on the `cacheTTL` option (default is 300 seconds) when initializing the client — for more information, see the caching section.
### Parameters
<ParamField query="secret_name" type="string" required>
The key of the secret to retrieve
</ParamField>
<ParamField query="type" type="string" default="personal" optional>
The type of the secret. Valid options are "shared" or "personal"
</ParamField>
### client.create_secret(secret_name, secret_value, options)
```py
new_api_key = client.create_secret("API_KEY", "FOO");
```
Create a new secret in Infisical.
### Parameters
<ParamField query="secret_name" type="string" required>
The key of the secret to create
</ParamField>
<ParamField query="secret_value" type="string" required>
The value of the secret to create
</ParamField>
<ParamField query="type" type="string" default="shared" optional>
The type of the secret. Valid options are "shared" or "personal". A personal secret can only be created if a shared secret with the same name exists.
</ParamField>
### client.update_secret(secret_name, secret_value, options)
```py
updated_api_key = client.update_secret("API_KEY", "BAR");
```
Update an existing secret in Infisical.
### Parameters
<ParamField query="secret_name" type="string" required>
The key of the secret to update
</ParamField>
<ParamField query="secret_value" type="string" required>
The new value of the secret
</ParamField>
<ParamField query="type" type="string" default="shared" optional>
The type of the secret. Valid options are "shared" or "personal"
</ParamField>
### client.delete_secret(secret_name, options)
```py
deleted_secret = client.delete_secret("API_KEY");
```
Delete a secret in Infisical.
### Parameters
<ParamField query="secret_name" type="string" required>
The key of the secret to delete
</ParamField>
<ParamField query="type" type="string" default="shared" optional>
The type of the secret. Valid options are "shared" or "personal"
</ParamField>
Follow this GitHub Follow this GitHub
[issue](https://github.com/Infisical/infisical/issues/433) to stay updated. [issue](https://github.com/Infisical/infisical/issues/433) to stay updated.

View File

@@ -1,5 +1,6 @@
--- ---
title: "Ruby" title: "Ruby"
icon: "gem"
--- ---
Coming soon. Coming soon.

View File

@@ -1,5 +1,6 @@
--- ---
title: "Rust" title: "Rust"
icon: "rust"
--- ---
Coming soon. Coming soon.

View File

@@ -3,12 +3,9 @@ title: "Overview"
description: "How to use Infisical SDKs to fetch back secrets for your app" 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: Whether it be for local development or production, Infisical SDKs provide the easiest way for your app to fetch back secrets using an [Infisical Token](/getting-started/dashboard/token).
- Local development: Replace 10s of environment variables in your `.env` file with 1 environment variable (the [Infisical Token](/getting-started/dashboard/token)). We currently have the [Node SDK](/sdks/languages/node) and [Python SDK](/sdks/languages/python) available with more language SDKs coming out soon:
- 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) - [Node](/sdks/languages/node)
- [Python](/sdks/languages/python) - [Python](/sdks/languages/python)