This commit is contained in:
2026-03-12 22:17:28 +01:00
parent f4f1ad9f9a
commit ceb4d8d24a
+5 -9
View File
@@ -19,19 +19,15 @@ logging.basicConfig(
class LoginError(Exception):
"""Raised when login fails due to invalid credentials or missing CSRF token."""
def read_secret(name):
with open(f"/run/secrets/{name}", "r") as f:
return f.read().strip()
def setup_vault():
"""Sets up and returns a Vault client."""
value_token = read_secret("vault_token")
vault_addr = os.environ.get("VAULT_ADDR", "https://vault.sectorq.eu")
try:
value_token = os.environ.get("VAULT_TOKEN")
if value_token is None:
raise KeyError
except KeyError:
value_token = prompt("Valult root token : ", is_password=True)
print("Use command export VAULT_TOKEN=")
os.environ["VAULT_TOKEN"] = value_token
client = hvac.Client(url=vault_addr, token=value_token)
# Check if connected