Skip to content

Commit 324d69a

Browse files
authored
Merge pull request #30 from Infisical/daniel/view-secret-permission
feat: add view secret value parameter to get/list secrets
2 parents 5e22583 + cb35c03 commit 324d69a

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ secrets = client.secrets.list_secrets(
8282
project_id="<project-id>",
8383
environment_slug="dev",
8484
secret_path="/",
85-
expand_secret_references=True,
86-
recursive=False,
87-
include_imports=True,
88-
tag_filters=[]
85+
expand_secret_references=True, # Optional
86+
view_secret_value=True, # Optional
87+
recursive=False, # Optional
88+
include_imports=True, # Optional
89+
tag_filters=[] # Optional
8990
)
9091
```
9192

@@ -94,6 +95,7 @@ secrets = client.secrets.list_secrets(
9495
- `environment_slug` (str): The environment in which to list secrets (e.g., "dev").
9596
- `secret_path` (str): The path to the secrets.
9697
- `expand_secret_references` (bool): Whether to expand secret references.
98+
- `view_secret_value` (bool): Whether or not to include the secret value in the response. If set to false, the `secretValue` will be masked with `<hidden-by-infisical>`. Defaults to true.
9799
- `recursive` (bool): Whether to list secrets recursively.
98100
- `include_imports` (bool): Whether to include imported secrets.
99101
- `tag_filters` (List[str]): Tags to filter secrets.
@@ -171,9 +173,10 @@ secret = client.secrets.get_secret_by_name(
171173
project_id="<project-id>",
172174
environment_slug="dev",
173175
secret_path="/",
174-
expand_secret_references=True,
175-
include_imports=True,
176-
version=None # Optional
176+
expand_secret_references=True, # Optional
177+
view_secret_value=True, # Optional
178+
include_imports=True, # Optional
179+
version=None # Optional
177180
)
178181
```
179182

@@ -183,6 +186,7 @@ secret = client.secrets.get_secret_by_name(
183186
- `environment_slug` (str): The environment in which to retrieve the secret.
184187
- `secret_path` (str): The path to the secret.
185188
- `expand_secret_references` (bool): Whether to expand secret references.
189+
- `view_secret_value` (bool): Whether or not to include the secret value in the response. If set to false, the `secretValue` will be masked with `<hidden-by-infisical>`. Defaults to true.
186190
- `include_imports` (bool): Whether to include imported secrets.
187191
- `version` (str, optional): The version of the secret to retrieve. Fetches the latest by default.
188192

infisical_sdk/api_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class BaseSecret(BaseModel):
7474
createdAt: str
7575
updatedAt: str
7676
secretMetadata: Optional[Dict[str, Any]] = None
77+
secretValueHidden: Optional[bool] = False
7778
secretReminderNote: Optional[str] = None
7879
secretReminderRepeatDays: Optional[int] = None
7980
skipMultilineEncoding: Optional[bool] = False

infisical_sdk/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def list_secrets(
209209
environment_slug: str,
210210
secret_path: str,
211211
expand_secret_references: bool = True,
212+
view_secret_value: bool = True,
212213
recursive: bool = False,
213214
include_imports: bool = True,
214215
tag_filters: List[str] = []) -> ListSecretsResponse:
@@ -217,6 +218,7 @@ def list_secrets(
217218
"workspaceId": project_id,
218219
"environment": environment_slug,
219220
"secretPath": secret_path,
221+
"viewSecretValue": str(view_secret_value).lower(),
220222
"expandSecretReferences": str(expand_secret_references).lower(),
221223
"recursive": str(recursive).lower(),
222224
"include_imports": str(include_imports).lower(),
@@ -241,10 +243,12 @@ def get_secret_by_name(
241243
secret_path: str,
242244
expand_secret_references: bool = True,
243245
include_imports: bool = True,
246+
view_secret_value: bool = True,
244247
version: str = None) -> BaseSecret:
245248

246249
params = {
247250
"workspaceId": project_id,
251+
"viewSecretValue": str(view_secret_value).lower(),
248252
"environment": environment_slug,
249253
"secretPath": secret_path,
250254
"expandSecretReferences": str(expand_secret_references).lower(),

0 commit comments

Comments
 (0)