toru-vault 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- toru_vault/vault.py +11 -2
- {toru_vault-0.2.0.dist-info → toru_vault-0.3.0.dist-info}/METADATA +13 -2
- {toru_vault-0.2.0.dist-info → toru_vault-0.3.0.dist-info}/RECORD +7 -7
- {toru_vault-0.2.0.dist-info → toru_vault-0.3.0.dist-info}/WHEEL +1 -1
- {toru_vault-0.2.0.dist-info → toru_vault-0.3.0.dist-info}/entry_points.txt +0 -0
- {toru_vault-0.2.0.dist-info → toru_vault-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {toru_vault-0.2.0.dist-info → toru_vault-0.3.0.dist-info}/top_level.txt +0 -0
toru_vault/vault.py
CHANGED
@@ -20,6 +20,7 @@ _KEYRING_SERVICE_NAME = "bitwarden_vault"
|
|
20
20
|
_KEYRING_BWS_TOKEN_KEY = "bws_token"
|
21
21
|
_KEYRING_ORG_ID_KEY = "organization_id"
|
22
22
|
_KEYRING_STATE_FILE_KEY = "state_file"
|
23
|
+
_KEYRING_PROJECT_ID_KEY = "project_id"
|
23
24
|
|
24
25
|
def _get_from_keyring_or_env(key, env_var):
|
25
26
|
"""
|
@@ -125,7 +126,7 @@ def env_load(project_id=None, override=False):
|
|
125
126
|
Load all secrets related to the project into environmental variables.
|
126
127
|
|
127
128
|
Args:
|
128
|
-
project_id (str, optional): Project ID to filter secrets
|
129
|
+
project_id (str, optional): Project ID to filter secrets. If None, will try to get from keyring or PROJECT_ID environment variable
|
129
130
|
override (bool, optional): Whether to override existing environment variables
|
130
131
|
"""
|
131
132
|
try:
|
@@ -138,6 +139,10 @@ def env_load(project_id=None, override=False):
|
|
138
139
|
logger.error("ORGANIZATION_ID not found in keyring or environment variable")
|
139
140
|
return
|
140
141
|
|
142
|
+
# If project_id is not provided, try to get it from keyring or environment variable
|
143
|
+
if project_id is None:
|
144
|
+
project_id = _get_from_keyring_or_env(_KEYRING_PROJECT_ID_KEY, "PROJECT_ID")
|
145
|
+
|
141
146
|
secrets = load_secrets_env(client, organization_id, project_id)
|
142
147
|
|
143
148
|
set_env_vars(secrets, override)
|
@@ -171,7 +176,7 @@ def get(project_id=None, use_keyring=True):
|
|
171
176
|
Return a dictionary of all project secrets with JIT decryption
|
172
177
|
|
173
178
|
Args:
|
174
|
-
project_id (str, optional): Project ID to filter secrets
|
179
|
+
project_id (str, optional): Project ID to filter secrets. If None, will try to get from keyring or PROJECT_ID environment variable
|
175
180
|
use_keyring (bool, optional): Whether to use system keyring (True) or in-memory encryption (False)
|
176
181
|
|
177
182
|
Returns:
|
@@ -188,6 +193,10 @@ def get(project_id=None, use_keyring=True):
|
|
188
193
|
logger.error("ORGANIZATION_ID not found in keyring or environment variable")
|
189
194
|
return {}
|
190
195
|
|
196
|
+
# If project_id is not provided, try to get it from keyring or environment variable
|
197
|
+
if project_id is None:
|
198
|
+
project_id = _get_from_keyring_or_env(_KEYRING_PROJECT_ID_KEY, "PROJECT_ID")
|
199
|
+
|
191
200
|
from .in_memory import load_secrets_memory
|
192
201
|
all_secrets = load_secrets_memory(client, organization_id, project_id)
|
193
202
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: toru-vault
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: ToruVault: A simple Python package for managing Bitwarden secrets
|
5
5
|
Author: Toru AI
|
6
6
|
Author-email: ToruAI <mpaszynski@toruai.com>
|
@@ -28,7 +28,7 @@ Dynamic: requires-python
|
|
28
28
|
A simple Python package for managing Bitwarden secrets with enhanced security.
|
29
29
|
|
30
30
|
|
31
|
-

|
32
32
|

|
33
33
|

|
34
34
|
|
@@ -118,6 +118,7 @@ Alternatively, you can set the following environment variables:
|
|
118
118
|
- `BWS_TOKEN`: Your Bitwarden access token
|
119
119
|
- `ORGANIZATION_ID`: Your Bitwarden organization ID
|
120
120
|
- `STATE_FILE`: Path to the state file (must be in an existing directory)
|
121
|
+
- `PROJECT_ID` (optional): Your Bitwarden project ID to filter secrets
|
121
122
|
- `API_URL` (optional): Defaults to "https://api.bitwarden.com"
|
122
123
|
- `IDENTITY_URL` (optional): Defaults to "https://identity.bitwarden.com"
|
123
124
|
|
@@ -159,6 +160,11 @@ print(os.environ.get("SECRET_NAME"))
|
|
159
160
|
# Load secrets for a specific project
|
160
161
|
vault.env_load(project_id="your-project-id")
|
161
162
|
|
163
|
+
# Alternatively, set PROJECT_ID environment variable and call without parameter
|
164
|
+
# export PROJECT_ID="your-project-id" # Linux/macOS
|
165
|
+
# set PROJECT_ID=your-project-id # Windows
|
166
|
+
vault.env_load() # Will use PROJECT_ID from environment
|
167
|
+
|
162
168
|
# Override existing environment variables (default: False)
|
163
169
|
vault.env_load(override=True)
|
164
170
|
```
|
@@ -178,6 +184,11 @@ secrets = vault.get(refresh=True)
|
|
178
184
|
# Get secrets for a specific project
|
179
185
|
secrets = vault.get(project_id="your-project-id")
|
180
186
|
|
187
|
+
# Alternatively, set PROJECT_ID environment variable and call without parameter
|
188
|
+
# export PROJECT_ID="your-project-id" # Linux/macOS
|
189
|
+
# set PROJECT_ID=your-project-id # Windows
|
190
|
+
secrets = vault.get() # Will use PROJECT_ID from environment
|
191
|
+
|
181
192
|
# Use in-memory encryption instead of system keyring
|
182
193
|
secrets = vault.get(use_keyring=False)
|
183
194
|
```
|
@@ -4,10 +4,10 @@ toru_vault/in_env.py,sha256=cr-Md7YODsRgeebPrzMcRsvojmVH4Mb-cmsUWFcj64k,6253
|
|
4
4
|
toru_vault/in_memory.py,sha256=Xt9F_a3it-SQ9f2lMdvO0e4aCkrcZR6bUujuMKHABS0,13608
|
5
5
|
toru_vault/lazy_dict.py,sha256=VRJAP-3SSk09GZh4le69kmHCoPzNOmP2ewWEEG5po6g,3054
|
6
6
|
toru_vault/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
7
|
-
toru_vault/vault.py,sha256=
|
8
|
-
toru_vault-0.
|
9
|
-
toru_vault-0.
|
10
|
-
toru_vault-0.
|
11
|
-
toru_vault-0.
|
12
|
-
toru_vault-0.
|
13
|
-
toru_vault-0.
|
7
|
+
toru_vault/vault.py,sha256=10FVC6kV-IU9p5ptYG48hyrloC_cI75dTALN3tpnGBY,9361
|
8
|
+
toru_vault-0.3.0.dist-info/licenses/LICENSE,sha256=TbuuchABSutbmmaI1M232F22GsaI88_hwEvto5w_Ux4,1063
|
9
|
+
toru_vault-0.3.0.dist-info/METADATA,sha256=Bso1OVGlp25FVExkRkNQgJJSn1ZxMss6HRzu5WuI9N8,8683
|
10
|
+
toru_vault-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
+
toru_vault-0.3.0.dist-info/entry_points.txt,sha256=dfqkbNftpmAv0iKzVgdkjymkCfj3TwzUrQm2PO7Xgxs,56
|
12
|
+
toru_vault-0.3.0.dist-info/top_level.txt,sha256=c9ulQ18kKs3HbkI5oeoLmnFTknjC0rY1BwsNLJKDua8,11
|
13
|
+
toru_vault-0.3.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|