mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Merge branch 'main' of https://github.com/Infisical/infisical
This commit is contained in:
1649
backend/package-lock.json
generated
1649
backend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-secrets-manager": "^3.303.0",
|
||||
"@aws-sdk/client-secrets-manager": "^3.306.0",
|
||||
"@godaddy/terminus": "^4.11.2",
|
||||
"@octokit/rest": "^19.0.5",
|
||||
"@sentry/node": "^7.41.0",
|
||||
"@sentry/tracing": "^7.46.0",
|
||||
"@sentry/tracing": "^7.47.0",
|
||||
"@types/crypto-js": "^4.1.1",
|
||||
"@types/libsodium-wrappers": "^0.7.10",
|
||||
"argon2": "^0.30.3",
|
||||
"await-to-js": "^3.0.0",
|
||||
"aws-sdk": "^2.1338.0",
|
||||
"axios": "^1.1.3",
|
||||
"axios": "^1.3.5",
|
||||
"axios-retry": "^3.4.0",
|
||||
"bcrypt": "^5.1.0",
|
||||
"bigint-conversion": "^2.2.2",
|
||||
|
||||
@@ -49,6 +49,8 @@ These examples demonstrate how to store and fetch environment variables from [In
|
||||
<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).
|
||||
|
||||
Using Python? We have a [Python SDK](/sdks/languages/python) as well.
|
||||
|
||||
### 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.
|
||||
|
||||
@@ -72,6 +72,17 @@ spec:
|
||||
` https://your-self-hosted-instace.com/api`
|
||||
|
||||
When `hostAPI` is not defined the operator fetches secrets from Infisical Cloud.
|
||||
|
||||
<Accordion title="Advanced use case">
|
||||
If you have installed your Infisical instance within the same cluster as the Infisical operator, you can optionally access the Infisical backend's service directly without having to route through the public internet.
|
||||
To achieve this, use the following address for the hostAPI field:
|
||||
|
||||
``` bash
|
||||
http://<backend-svc-name>.<namespace>.svc.cluster.local:4000/api
|
||||
```
|
||||
|
||||
Make sure to replace `<backend-svc-name>` and `<namespace>` with the appropriate values for your backend service and namespace.
|
||||
</Accordion>
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="authentication">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: "Go"
|
||||
icon: "golang"
|
||||
---
|
||||
|
||||
Coming soon.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: "Java"
|
||||
icon: "java"
|
||||
---
|
||||
|
||||
Coming soon.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
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.
|
||||
@@ -7,8 +8,8 @@ If you're working with Node.js, the official [infisical-node](https://github.com
|
||||
## Basic Usage
|
||||
|
||||
```js
|
||||
import InfisicalClient from "infisical-node";
|
||||
import express from "express";
|
||||
import InfisicalClient from "infisical-node";
|
||||
const app = express();
|
||||
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.
|
||||
|
||||
```bash
|
||||
npm install infisical-node --save
|
||||
```console
|
||||
$ npm install infisical-node --save
|
||||
```
|
||||
|
||||
## Configuration
|
||||
@@ -75,39 +76,54 @@ Import the SDK and create a client instance with your Infisical token.
|
||||
|
||||
</Tabs>
|
||||
|
||||
<ResponseField name="options" type="object">
|
||||
### Parameters
|
||||
|
||||
<ParamField query="options" type="object">
|
||||
<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
|
||||
and environment
|
||||
</ResponseField>
|
||||
<ResponseField
|
||||
name="siteURL"
|
||||
</ParamField>
|
||||
<ParamField
|
||||
query="siteURL"
|
||||
type="string"
|
||||
default="https://app.infisical.com"
|
||||
optional
|
||||
>
|
||||
Your self-hosted absolute site URL including the protocol (e.g.
|
||||
`https://app.infisical.com`)
|
||||
</ResponseField>
|
||||
<ResponseField name="cacheTTL" type="number" default="300">
|
||||
</ParamField>
|
||||
<ParamField query="cacheTTL" type="number" default="300" optional>
|
||||
Time-to-live (in seconds) for refreshing cached secrets. Default: `300`.
|
||||
</ResponseField>
|
||||
<ResponseField name="debug" type="boolean" default="false">
|
||||
</ParamField>
|
||||
<ParamField query="debug" type="boolean" default="false" optional>
|
||||
Whether or not debug mode is on
|
||||
</ResponseField>
|
||||
</ParamField>
|
||||
</Expandable>
|
||||
</ResponseField>
|
||||
</ParamField>
|
||||
|
||||
## 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.
|
||||
|
||||
<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
|
||||
|
||||
### infisical.getSecret(secretName, options)
|
||||
### client.getAllSecrets()
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
@@ -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.
|
||||
|
||||
### Parameters
|
||||
|
||||
<ResponseField name="secretName" type="string" required>
|
||||
<ParamField query="secretName" type="string" required>
|
||||
The key of the secret to retrieve
|
||||
</ResponseField>
|
||||
<ResponseField name="options" type="object">
|
||||
</ParamField>
|
||||
<ParamField query="options" type="object" optional>
|
||||
<Expandable title="properties">
|
||||
<ResponseField name="type" type="string">
|
||||
"personal" (default) or "shared".
|
||||
</ResponseField>
|
||||
<ParamField query="type" type="string" default="personal" optional>
|
||||
The type of the secret. Valid options are "shared" or "personal"
|
||||
</ParamField>
|
||||
</Expandable>
|
||||
</ResponseField>
|
||||
</ParamField>
|
||||
|
||||
### infisical.createSecret(secretName, secretValue, options)
|
||||
### client.createSecret(secretName, secretValue, options)
|
||||
|
||||
```js
|
||||
const newApiKey = await infisical.createSecret("API_KEY", "FOO");
|
||||
const newApiKey = await client.createSecret("API_KEY", "FOO");
|
||||
```
|
||||
|
||||
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
|
||||
</ResponseField>
|
||||
<ResponseField name="secretName" type="string" required>
|
||||
</ParamField>
|
||||
<ParamField query="secretName" type="string" required>
|
||||
The value of the secret to create
|
||||
</ResponseField>
|
||||
<ResponseField name="options" type="object">
|
||||
</ParamField>
|
||||
<ParamField query="options" type="object" default="object" optional>
|
||||
<Expandable title="properties">
|
||||
<ResponseField name="type" type="string">
|
||||
"shared" (default) or "personal". A personal secret can only be created if a shared secret with the same name exists.
|
||||
</ResponseField>
|
||||
<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>
|
||||
</Expandable>
|
||||
</ResponseField>
|
||||
</ParamField>
|
||||
|
||||
### infisical.updateSecret(secretName, secretValue, options)
|
||||
### client.updateSecret(secretName, secretValue, options)
|
||||
|
||||
```js
|
||||
const updatedApiKey = await infisical.updateSecret("API_KEY", "BAR");
|
||||
const updatedApiKey = await client.updateSecret("API_KEY", "BAR");
|
||||
```
|
||||
|
||||
Update an existing secret in Infisical.
|
||||
|
||||
<ResponseField name="secretName" type="string" required>
|
||||
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>
|
||||
### Parameters
|
||||
|
||||
### 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
|
||||
const deletedSecret = await infisical.deleteSecret("API_KEY");
|
||||
const deletedSecret = await client.deleteSecret("API_KEY");
|
||||
```
|
||||
|
||||
Delete a secret in Infisical.
|
||||
|
||||
<ResponseField name="secretName" type="string" required>
|
||||
<ParamField query="secretName" type="string" required>
|
||||
The key of the secret to delete
|
||||
</ResponseField>
|
||||
<ResponseField name="options" type="object">
|
||||
</ParamField>
|
||||
<ParamField query="options" type="object" default="object" optional>
|
||||
<Expandable title="properties">
|
||||
<ResponseField name="type" type="string">
|
||||
"shared" (default) or "personal". Note that deleting a shared secret also deletes all associated personal secrets.
|
||||
</ResponseField>
|
||||
<ParamField query="type" type="string" default="shared" optional>
|
||||
The type of the secret. Valid options are "shared" or "personal". Note that deleting a shared secret also deletes all associated personal secrets.
|
||||
</ParamField>
|
||||
</Expandable>
|
||||
</ResponseField>
|
||||
</ParamField>
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,169 @@
|
||||
---
|
||||
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
|
||||
[issue](https://github.com/Infisical/infisical/issues/433) to stay updated.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: "Ruby"
|
||||
icon: "gem"
|
||||
---
|
||||
|
||||
Coming soon.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
title: "Rust"
|
||||
icon: "rust"
|
||||
---
|
||||
|
||||
Coming soon.
|
||||
|
||||
@@ -3,12 +3,9 @@ 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:
|
||||
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)).
|
||||
- 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:
|
||||
We currently have the [Node SDK](/sdks/languages/node) and [Python SDK](/sdks/languages/python) available with more language SDKs coming out soon:
|
||||
|
||||
- [Node](/sdks/languages/node)
|
||||
- [Python](/sdks/languages/python)
|
||||
|
||||
Reference in New Issue
Block a user