v1.0
- Show URLs
This commit is contained in:
31
README.md
31
README.md
@@ -0,0 +1,31 @@
|
||||
# bw-get: a CLI tool for Bitwarden
|
||||
|
||||
## Installation
|
||||
|
||||
Requirements
|
||||
- Python > 3.9
|
||||
- pipx
|
||||
- An already configured and logged-in (`bw login`) Bitwarden CLI
|
||||
|
||||
```bash
|
||||
git clone https://git.fabianvk.nl/faab/bw_get.git
|
||||
cd bw_get/
|
||||
pipx install .
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
# Optionally unlock the vault, so you're not prompted for master password every time
|
||||
$ export BW_SESSION=`bw unlock --raw`
|
||||
|
||||
$ bw-get test
|
||||
? Select item test.example.nl (faab)
|
||||
name : test.example.nl
|
||||
id : 4afbb65b-c6c5-4035-9cb7-52d0b827a1da
|
||||
url : http://test.example.nl/phpmyadmin/
|
||||
username : faab
|
||||
password : SecretPassword
|
||||
|
||||
Password has been copied to the clipboard.
|
||||
```
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "bw-get"
|
||||
version = "0.0.1"
|
||||
version = "1.0.0"
|
||||
authors = [
|
||||
{name="Fabian van Koppen", email="f@bianvk.nl"}
|
||||
]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import json
|
||||
import questionary
|
||||
import argparse
|
||||
import typer
|
||||
import pyotp
|
||||
|
||||
@@ -15,8 +14,8 @@ home = environ.get('HOME')
|
||||
|
||||
def check_lock() -> bool:
|
||||
check = run(['bw', 'unlock', '--check'], stdout=DEVNULL, stderr=DEVNULL)
|
||||
if check.returncode != 0:
|
||||
return False
|
||||
|
||||
if check.returncode != 0: return False
|
||||
else: return True
|
||||
|
||||
def new_session():
|
||||
@@ -31,10 +30,10 @@ def new_session():
|
||||
|
||||
def get_password(search_string: Annotated[str, typer.Argument(help="The term to search for in Vaultwarden")] = ""):
|
||||
|
||||
if check_lock is False:
|
||||
if check_lock() is False:
|
||||
new_session()
|
||||
|
||||
list_items_cmd = run(['bw', 'list', 'items'], capture_output=True)
|
||||
list_items_cmd = run(['bw', 'list', 'items', '--search', search_string], capture_output=True)
|
||||
|
||||
items = json.loads(list_items_cmd.stdout)
|
||||
|
||||
@@ -66,7 +65,12 @@ def get_password(search_string: Annotated[str, typer.Argument(help="The term to
|
||||
|
||||
print(f"name\t\t: {filtered_list[chosen_index]['name']}")
|
||||
print(f"id\t\t: {filtered_list[chosen_index]['id']}")
|
||||
# Loop over URIs
|
||||
|
||||
if len(filtered_list[chosen_index]['login']['uris']) > 0:
|
||||
for url in filtered_list[chosen_index]['login']['uris']:
|
||||
print(f"url\t\t: {url['uri']}")
|
||||
|
||||
|
||||
print(f"username\t: {filtered_list[chosen_index]['login']['username']}")
|
||||
print(f"password\t: \033[34m\033[44m{filtered_list[chosen_index]['login']['password']}\033[0m")
|
||||
if filtered_list[chosen_index]['login']['totp']:
|
||||
|
||||
Reference in New Issue
Block a user