xenoslib 0.1.29.19__tar.gz → 0.1.29.21__tar.gz
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.
- {xenoslib-0.1.29.19/xenoslib.egg-info → xenoslib-0.1.29.21}/PKG-INFO +1 -1
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/about.py +1 -1
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/extend.py +14 -6
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21/xenoslib.egg-info}/PKG-INFO +1 -1
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/LICENSE +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/README.md +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/setup.cfg +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/setup.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/__init__.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/__main__.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/base.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/dev.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/linux.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/mail.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/mock.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/onedrive.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/win_trayicon.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib/windows.py +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib.egg-info/SOURCES.txt +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib.egg-info/dependency_links.txt +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib.egg-info/requires.txt +0 -0
- {xenoslib-0.1.29.19 → xenoslib-0.1.29.21}/xenoslib.egg-info/top_level.txt +0 -0
|
@@ -221,10 +221,11 @@ class ConfigLoader(SingletonWithArgs):
|
|
|
221
221
|
with open(config_file_path, "r") as f:
|
|
222
222
|
self._raw_config = yaml.safe_load(f) or {}
|
|
223
223
|
|
|
224
|
-
if
|
|
225
|
-
self.
|
|
224
|
+
if vault_secret_id is not None:
|
|
225
|
+
self.vault_secret_id = vault_secret_id
|
|
226
|
+
self._check_and_renew_vault_client()
|
|
226
227
|
|
|
227
|
-
def _init_vault_client(self
|
|
228
|
+
def _init_vault_client(self):
|
|
228
229
|
"""Initialize and authenticate the Vault client (imports hvac on demand).
|
|
229
230
|
|
|
230
231
|
Args:
|
|
@@ -251,12 +252,19 @@ class ConfigLoader(SingletonWithArgs):
|
|
|
251
252
|
if not all([vault_url, vault_space, vault_role_id]):
|
|
252
253
|
raise KeyError("Missing required Vault configuration in config.yml")
|
|
253
254
|
|
|
254
|
-
self.vault_client = hvac.Client(url=vault_url, namespace=vault_space)
|
|
255
|
-
|
|
255
|
+
self.vault_client = hvac.Client(url=vault_url, namespace=vault_space, timeout=45)
|
|
256
|
+
help(hvac.Client)
|
|
257
|
+
self.vault_client.auth.approle.login(role_id=vault_role_id, secret_id=self.vault_secret_id)
|
|
256
258
|
except Exception as e:
|
|
257
259
|
self.vault_client = None
|
|
258
260
|
raise Exception(f"Failed to initialize Vault client: {str(e)}")
|
|
259
261
|
|
|
262
|
+
def _check_and_renew_vault_client(self):
|
|
263
|
+
# 检查当前Token的状态,包括过期时间和可续租性
|
|
264
|
+
if not self.vault_client or not self.vault_client.is_authenticated():
|
|
265
|
+
# 如果当前Token无效,则重新认证
|
|
266
|
+
self._init_vault_client()
|
|
267
|
+
|
|
260
268
|
def get(self, section, key_name, use_cache=True):
|
|
261
269
|
"""Retrieve a configuration value.
|
|
262
270
|
|
|
@@ -366,5 +374,5 @@ if __name__ == "__main__":
|
|
|
366
374
|
|
|
367
375
|
# This will only work if you provide a valid Vault secret ID
|
|
368
376
|
# and hvac package is installed
|
|
369
|
-
config_with_vault = ConfigLoader("config.yml", vault_secret_id="
|
|
377
|
+
config_with_vault = ConfigLoader("config.yml", vault_secret_id=os.getenv("VAULT_CF_LANDSCAPES_SECRET_ID"))
|
|
370
378
|
print("With Vault:", config_with_vault.get("cis", "cis_client_id"))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|