Switched to HVAC Agent instead of connecting to the vault directly

This commit is contained in:
florian 2025-10-04 22:14:47 +02:00
parent d356ec8428
commit f67fd99333

View File

@ -1,18 +1,14 @@
import base64
import hvac
import base64
import os
client = hvac.Client(
url='http://127.0.0.1:8200',
token='root'
)
HVAC_AGENT_URL = os.getenv("HVAC_AGENT_URL","http://vault-agent:8201")
client = hvac.Client(url=HVAC_AGENT_URL)
def decrypt_token(ciphertext: str) -> str:
response = client.secrets.transit.decrypt_data(
name='push-tokens',
ciphertext=ciphertext
)
plaintext_b64 = response['data']['plaintext']
return base64.b64decode(plaintext_b64).decode()
response = client.secrets.transit.decrypt_data(
name="push-tokens",
ciphertext=ciphertext
)
plaintext_b64 = response["data"]["plaintext"]
return base64.b64decode(plaintext_b64).decode()