extend bitwarden credential to support vaultwarden (#3268)
This commit is contained in:
@@ -282,6 +282,7 @@ class Settings(BaseSettings):
|
|||||||
BITWARDEN_CLIENT_ID: str | None = None
|
BITWARDEN_CLIENT_ID: str | None = None
|
||||||
BITWARDEN_CLIENT_SECRET: str | None = None
|
BITWARDEN_CLIENT_SECRET: str | None = None
|
||||||
BITWARDEN_MASTER_PASSWORD: str | None = None
|
BITWARDEN_MASTER_PASSWORD: str | None = None
|
||||||
|
BITWARDEN_EMAIL: str | None = None
|
||||||
OP_SERVICE_ACCOUNT_TOKEN: str | None = None
|
OP_SERVICE_ACCOUNT_TOKEN: str | None = None
|
||||||
|
|
||||||
# Skyvern Auth Bitwarden Settings
|
# Skyvern Auth Bitwarden Settings
|
||||||
|
|||||||
@@ -184,8 +184,8 @@ class BitwardenService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def get_secret_value_from_url(
|
async def get_secret_value_from_url(
|
||||||
client_id: str,
|
client_id: str | None,
|
||||||
client_secret: str,
|
client_secret: str | None,
|
||||||
master_password: str,
|
master_password: str,
|
||||||
bw_organization_id: str | None,
|
bw_organization_id: str | None,
|
||||||
bw_collection_ids: list[str] | None,
|
bw_collection_ids: list[str] | None,
|
||||||
@@ -249,8 +249,8 @@ class BitwardenService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _get_secret_value_from_url(
|
async def _get_secret_value_from_url(
|
||||||
client_id: str,
|
client_id: str | None,
|
||||||
client_secret: str,
|
client_secret: str | None,
|
||||||
master_password: str,
|
master_password: str,
|
||||||
bw_organization_id: str | None,
|
bw_organization_id: str | None,
|
||||||
bw_collection_ids: list[str] | None,
|
bw_collection_ids: list[str] | None,
|
||||||
@@ -382,8 +382,8 @@ class BitwardenService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def get_sensitive_information_from_identity(
|
async def get_sensitive_information_from_identity(
|
||||||
client_id: str,
|
client_id: str | None,
|
||||||
client_secret: str,
|
client_secret: str | None,
|
||||||
master_password: str,
|
master_password: str,
|
||||||
bw_organization_id: str | None,
|
bw_organization_id: str | None,
|
||||||
bw_collection_ids: list[str] | None,
|
bw_collection_ids: list[str] | None,
|
||||||
@@ -438,8 +438,8 @@ class BitwardenService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _get_sensitive_information_from_identity(
|
async def _get_sensitive_information_from_identity(
|
||||||
client_id: str,
|
client_id: str | None,
|
||||||
client_secret: str,
|
client_secret: str | None,
|
||||||
master_password: str,
|
master_password: str,
|
||||||
collection_id: str,
|
collection_id: str,
|
||||||
identity_key: str,
|
identity_key: str,
|
||||||
@@ -516,15 +516,18 @@ class BitwardenService:
|
|||||||
await BitwardenService.logout()
|
await BitwardenService.logout()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def login(client_id: str, client_secret: str) -> None:
|
async def login(client_id: str | None, client_secret: str | None) -> None:
|
||||||
"""
|
"""
|
||||||
Log in to the Bitwarden CLI.
|
Log in to the Bitwarden CLI.
|
||||||
"""
|
"""
|
||||||
env = {
|
env = {
|
||||||
"BW_CLIENTID": client_id,
|
"BW_CLIENTID": client_id or "",
|
||||||
"BW_CLIENTSECRET": client_secret,
|
"BW_CLIENTSECRET": client_secret or "",
|
||||||
}
|
}
|
||||||
login_command = ["bw", "login", "--apikey"]
|
if settings.BITWARDEN_EMAIL and settings.BITWARDEN_MASTER_PASSWORD:
|
||||||
|
login_command = ["bw", "login", settings.BITWARDEN_EMAIL, settings.BITWARDEN_MASTER_PASSWORD]
|
||||||
|
else:
|
||||||
|
login_command = ["bw", "login", "--apikey"]
|
||||||
login_result = await BitwardenService.run_command(login_command, env)
|
login_result = await BitwardenService.run_command(login_command, env)
|
||||||
|
|
||||||
# Validate the login result
|
# Validate the login result
|
||||||
@@ -588,8 +591,8 @@ class BitwardenService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _get_credit_card_data(
|
async def _get_credit_card_data(
|
||||||
client_id: str,
|
client_id: str | None,
|
||||||
client_secret: str,
|
client_secret: str | None,
|
||||||
master_password: str,
|
master_password: str,
|
||||||
bw_organization_id: str | None,
|
bw_organization_id: str | None,
|
||||||
bw_collection_ids: list[str] | None,
|
bw_collection_ids: list[str] | None,
|
||||||
@@ -664,8 +667,8 @@ class BitwardenService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def get_credit_card_data(
|
async def get_credit_card_data(
|
||||||
client_id: str,
|
client_id: str | None,
|
||||||
client_secret: str,
|
client_secret: str | None,
|
||||||
master_password: str,
|
master_password: str,
|
||||||
bw_organization_id: str | None,
|
bw_organization_id: str | None,
|
||||||
bw_collection_ids: list[str] | None,
|
bw_collection_ids: list[str] | None,
|
||||||
|
|||||||
@@ -416,9 +416,9 @@ class WorkflowRunContext:
|
|||||||
LOG.error(f"Failed to get Bitwarden login credentials from AWS secrets. Error: {e}")
|
LOG.error(f"Failed to get Bitwarden login credentials from AWS secrets. Error: {e}")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
if not client_id:
|
if not client_id and not settings.BITWARDEN_EMAIL:
|
||||||
raise ValueError("Bitwarden client ID not found")
|
raise ValueError("Bitwarden client ID not found")
|
||||||
if not client_secret:
|
if not client_secret and not settings.BITWARDEN_EMAIL:
|
||||||
raise ValueError("Bitwarden client secret not found")
|
raise ValueError("Bitwarden client secret not found")
|
||||||
if not master_password:
|
if not master_password:
|
||||||
raise ValueError("Bitwarden master password not found")
|
raise ValueError("Bitwarden master password not found")
|
||||||
@@ -519,9 +519,9 @@ class WorkflowRunContext:
|
|||||||
LOG.error(f"Failed to get Bitwarden login credentials from AWS secrets. Error: {e}")
|
LOG.error(f"Failed to get Bitwarden login credentials from AWS secrets. Error: {e}")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
if not client_id:
|
if not client_id and not settings.BITWARDEN_EMAIL:
|
||||||
raise ValueError("Bitwarden client ID not found")
|
raise ValueError("Bitwarden client ID not found")
|
||||||
if not client_secret:
|
if not client_secret and not settings.BITWARDEN_EMAIL:
|
||||||
raise ValueError("Bitwarden client secret not found")
|
raise ValueError("Bitwarden client secret not found")
|
||||||
if not master_password:
|
if not master_password:
|
||||||
raise ValueError("Bitwarden master password not found")
|
raise ValueError("Bitwarden master password not found")
|
||||||
@@ -586,9 +586,9 @@ class WorkflowRunContext:
|
|||||||
LOG.error(f"Failed to get Bitwarden login credentials from AWS secrets. Error: {e}")
|
LOG.error(f"Failed to get Bitwarden login credentials from AWS secrets. Error: {e}")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
if not client_id:
|
if not client_id and not settings.BITWARDEN_EMAIL:
|
||||||
raise ValueError("Bitwarden client ID not found")
|
raise ValueError("Bitwarden client ID not found")
|
||||||
if not client_secret:
|
if not client_secret and not settings.BITWARDEN_EMAIL:
|
||||||
raise ValueError("Bitwarden client secret not found")
|
raise ValueError("Bitwarden client secret not found")
|
||||||
if not master_password:
|
if not master_password:
|
||||||
raise ValueError("Bitwarden master password not found")
|
raise ValueError("Bitwarden master password not found")
|
||||||
|
|||||||
Reference in New Issue
Block a user