Python client for KeePassHTTP to interact with KeePass's credentials
Project description
KeePassHTTP
Python client for KeePassHTTP to interact with KeePass's credentials.
Install
$ pip install keepasshttp
Usage
import keepasshttp
# get single credential
credential = keepasshttp.get("my_credential_name_or_url")
print(credential.login)
print(credential.password)
# find all credentials's name
credentials = keepasshttp.list()
# fetch all partiall matching credentials
credentials = keepasshttp.search("my_credential_name_or_url")
# create a new keepasshttp entry
keepasshttp.create("login", "password", "url")
# update a keepasshttp entry
credential.password = "new password"
# or
keepasshttp.update("login", "password", "url", "uuid")
Command line
KeePassHTTP can also be called from command line:
$ python -m keepasshttp --help
usage: keepasshttp [-h] [-c CONFIG_PATH] [-u URL]
[-f {python,text,table,json,csv}]
credential [credential ...]
Fetch credentials from keepass
positional arguments:
credential Url or name to match credentials from keepass database
optional arguments:
-h, --help show this help message and exit
-c CONFIG_PATH, --config CONFIG_PATH
alternative path for keepasshttp's AES exchange key
(default: ~/.python_keepass_http)
-u URL, --url URL alternative url for keepasshttp server (default:
'http://localhost:19455/')
-f {python,text,table,json,csv}, --format {python,text,table,json,csv}
output format for credentials
$ python -m keepathhttp my_credential_name_or_url
my_credential_name_or_url
- login: login
- password: password
- name: test
- url: my_credential_name_or_url
- id: ABCDEF1234567890ABCDEF1234567890
- fields: []
Configuration
By default, this module will write AES association key to ~/.python_keepass_http
and use http://localhost:19455/
to connect to the KeePassHTTP server.
To change theses parameters, instantiate keepasshttp.KeePassHTTP
class with different values.
from keepasshttp import KeePassHTTP
kph = KeePassHTTP(
storage="./keepasshttp_key",
url="https://example.com:1337/")
kph.get("...")
...
Testing
You can simply run the tests using:
python -m unittest discover
KeePassHTTP
calls are mocked, to run the tests against a real server, you need to:
- open
tests/test_database.kdbx
inKeePass
password istest
- set
TEST_WITH_KEEPASS
environment variable - run test normally
Coverage
To run tests with coverage:
pip install pytest-cov
pytest --cov
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
keepasshttp-1.2.3.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for keepasshttp-1.2.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 802b860eb8d6922d37765591b968dc1368519e7ee360a7c68d8c5fb10ad6cf42 |
|
MD5 | 56b3a143e61011a12571081859b7bd69 |
|
BLAKE2b-256 | 759714974e4276affe5bb82386a49eb743c8879f36c59e2282d4c0db848dd67c |