mirror of
https://gitlab.sectorq.eu/jaydee/api_server.git
synced 2026-09-17 02:12:55 +02:00
build
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user