最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

security - Access entry from Vaultwarden with Python - Stack Overflow

programmeradmin0浏览0评论

I want to use my vaultwarden docker instance on the server to handle multiple passwords securely. Within my python project I want to access one of the stored entries.

To access the vaultwarden I want to use

In my current code I can see all the ciphers in the collection. But I struggle to access the password for later use.

from uuid import UUID
from vaultwarden.clients.bitwarden import BitwardenAPIClient
from vaultwarden.models.bitwarden import OrganizationCollection, get_organization
from vaultwarden.utils.crypto import decode_cipher_string
import os

from dotenv import load_dotenv

load_dotenv()

bitwarden_client = BitwardenAPIClient(os.getenv("VW_URL"),
                                      os.getenv("VW_USER_MAIL"),
                                      os.getenv("VW_USER_PW"),
                                      os.getenv("VW_CLIENT_ID"),
                                      os.getenv("VW_CLIENT_SECRET"),
                                      os.getenv("VW_DEVICE_ID"))

org_uuid = UUID('...')
collection_uuid = UUID('...')

orga = get_organization(bitwarden_client, org_uuid)
collection_elements = orga.ciphers(collection_uuid)

for element in collection_elements:
    if element.Name == "Grafana":
        password_encrypted = element.model_extra["data"]["password"]
        password_decrypted = decode_cipher_string(password_encrypted)
        print(password_decrypted)

Any suggestion for accessing the password for later use inside of the program?

I want to use my vaultwarden docker instance on the server to handle multiple passwords securely. Within my python project I want to access one of the stored entries.

To access the vaultwarden I want to use https://github.com/numberly/python-vaultwarden

In my current code I can see all the ciphers in the collection. But I struggle to access the password for later use.

from uuid import UUID
from vaultwarden.clients.bitwarden import BitwardenAPIClient
from vaultwarden.models.bitwarden import OrganizationCollection, get_organization
from vaultwarden.utils.crypto import decode_cipher_string
import os

from dotenv import load_dotenv

load_dotenv()

bitwarden_client = BitwardenAPIClient(os.getenv("VW_URL"),
                                      os.getenv("VW_USER_MAIL"),
                                      os.getenv("VW_USER_PW"),
                                      os.getenv("VW_CLIENT_ID"),
                                      os.getenv("VW_CLIENT_SECRET"),
                                      os.getenv("VW_DEVICE_ID"))

org_uuid = UUID('...')
collection_uuid = UUID('...')

orga = get_organization(bitwarden_client, org_uuid)
collection_elements = orga.ciphers(collection_uuid)

for element in collection_elements:
    if element.Name == "Grafana":
        password_encrypted = element.model_extra["data"]["password"]
        password_decrypted = decode_cipher_string(password_encrypted)
        print(password_decrypted)

Any suggestion for accessing the password for later use inside of the program?

Share Improve this question asked Feb 5 at 12:50 betarosbetaros 6029 silver badges25 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I solved the issue:

for element in collection_elements:
if element.Name == "Grafana":
    password_encrypted = element.model_extra["data"]["password"]
    password_decrypted = decrypt(password_encrypted, orga.key())
    print(password_decrypted)

I needed to get the key of the organization to decrypt the encrypted password with the decrypt() methode.

发布评论

评论列表(0)

  1. 暂无评论