if bitwarden TOTP is not defined, do not pass totp as part of the credential to llm (#899)

This commit is contained in:
Kerem Yilmaz
2024-10-02 14:02:49 -07:00
committed by GitHub
parent 17c680d439
commit 4f6feae03e
2 changed files with 9 additions and 6 deletions

View File

@@ -177,11 +177,13 @@ class BitwardenService:
{
BitwardenConstants.USERNAME: item["login"]["username"],
BitwardenConstants.PASSWORD: item["login"]["password"],
BitwardenConstants.TOTP: totp_code,
}
for item in items
if "login" in item
]
if totp_code:
for credential in credentials:
credential[BitwardenConstants.TOTP] = totp_code
if len(credentials) == 0:
return {}

View File

@@ -182,15 +182,16 @@ class WorkflowRunContext:
# password secret
password_secret_id = f"{random_secret_id}_password"
self.secrets[password_secret_id] = secret_credentials[BitwardenConstants.PASSWORD]
totp_secret_id = f"{random_secret_id}_totp"
self.secrets[totp_secret_id] = BitwardenConstants.TOTP
self.values[parameter.key] = {
"username": username_secret_id,
"password": password_secret_id,
"totp": totp_secret_id,
}
if BitwardenConstants.TOTP in secret_credentials and secret_credentials[BitwardenConstants.TOTP]:
totp_secret_id = f"{random_secret_id}_totp"
self.secrets[totp_secret_id] = BitwardenConstants.TOTP
self.values[parameter.key]["totp"] = totp_secret_id
except BitwardenBaseError as e:
LOG.error(f"Failed to get secret from Bitwarden. Error: {e}")
raise e