13 lines
354 B
Python
13 lines
354 B
Python
import hvac
|
|
import base64
|
|
import os
|
|
|
|
HVAC_AGENT_URL = os.getenv("HVAC_AGENT_URL","http://vault-agent:8201")
|
|
client = hvac.Client(url=HVAC_AGENT_URL)
|
|
|
|
def encrypt_token(token: str) -> str:
|
|
response = client.secrets.transit.encrypt_data(
|
|
name='push-tokens',
|
|
plaintext=base64.b64encode(token.encode()).decode()
|
|
)
|
|
return response['data']['ciphertext'] |