From bfa433a01d1042270c82fcc0c40619ca24909e2c Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 5 Dec 2026 22:09:29 +0100 Subject: WIP Somewhat blocked by https://bugzilla.redhat.com/show_bug.cgi?id=2521543 --- scripts/p7s/bitwarden.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'scripts/p7s/bitwarden.py') diff --git a/scripts/p7s/bitwarden.py b/scripts/p7s/bitwarden.py index ab6cc4f2..6015cbbb 100644 --- a/scripts/p7s/bitwarden.py +++ b/scripts/p7s/bitwarden.py @@ -1,7 +1,11 @@ import contextlib import json import os +import pathlib import subprocess +import tempfile +import urllib.request +import zipfile class Bitwarden(): @@ -40,3 +44,25 @@ def get_item(server, email, uuid): with b.login(server, email): b.sync() return b.get_item(uuid) + + +@contextlib.contextmanager +def default(): + b = Bitwarden() + with b.login("https://vaultwarden.pdp7.net", "alex@corcoles.net"): + b.sync() + yield b + + +def install_cli(version): + with tempfile.TemporaryDirectory() as tempdir: + tempdir = pathlib.Path(tempdir) + zip = tempdir / "zip" + with urllib.request.urlopen(f"https://github.com/bitwarden/clients/releases/download/cli-v{version}/bw-oss-linux-{version}.zip") as urlopen: + zip.write_bytes(urlopen.read()) + with zipfile.ZipFile(zip) as zip: + with zip.open("bw") as bw: + bw_path = pathlib.Path.home() / ".local" / "bin" / "bw" + bw_path.unlink() + bw_path.write_bytes(bw.read()) + bw_path.chmod(0o555) -- cgit v1.2.3