Asyncio and aiohttp based library and CLI to connect to haveibeenpwned.
Project description
haveibeenpwned-asyncio
v0.0.1
Library to query and check haveibeenpwned with the aiohttp library.
NB: I have added async to sync methods if you are not writing async code. Every query function has an corresponding synchronous call -> example query_account_sync()
Install
pip install haveibeenpwned-asyncio
# or
poetry add haveibeenpwned-asyncio
Usage
See example.py for more uses
Ex:
import os
from haveibeenpwned_asyncio import haveIbeenPwnedPasswords, haveIbeenPwnedAccount
import asyncio
if __name__ == "__main__":
# Validation Class, inherits from Indentity Class
loop = asyncio.get_event_loop()
passwords = ['test@1234', 'test$1234']
accounts = ['admin@gmail.com', 'test@test.com']
print(
loop.run_until_complete(haveIbeenPwnedPasswords(
passwords=passwords, semaphore_max=10
).query_passwords()
)
)
test_acc = haveIbeenPwnedAccount(
accounts=accounts,
semaphore_max=10,
api_key=os.getenv("HAVEIBEENPWNED_API_KEY", None)
)
print(loop.run_until_complete(test_acc.query_accounts()))
print(test_acc.query_accounts_sync())
API Key
Some of the endpoints (breachedAccount) require authentication in the v3 of the API. This is to prevent script kiddies and abuse of the api, see blog post: https://www.troyhunt.com/authentication-and-the-have-i-been-pwned-api/
To get an API key follow: https://haveibeenpwned.com/API/Key
Usage:
# Could use env variables
haveIbeenPwnedAccount(
accounts=accounts,
semaphore_max=10,
api_key=os.getenv("HAVEIBEENPWNED_API_KEY", None))
# or
haveIbeenPwnedAccount(
accounts=accounts,
semaphore_max=10,
api_key='xxxxxxxxx')
CLI
Includes a CLI interface using pythong click library
(.venv) goose@pop-os:~/Development/haveibeenpwned_asyncio$ haveibeenpwned_async --help
Usage: haveibeenpwned_async [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
accounts
passwords
pastes
Speed
Check the file run_test_speed.py. This will give you an idea of the speedup asyncio does with multiple IO bound network calls
TODO:
- Add API key to github actions for pytest to pass on breachedAccount
Donations
Please feel free to buy me a cup of coffee as I pay a monthly $3 to test the library against haveibeenpwned's monthly billed API key
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
Built Distribution
Hashes for haveibeenpwned-asyncio-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb1eb9aeecba33760802696d31b035c2811d342d42d7239c4d61341e223317f1 |
|
MD5 | c017494dcf8fa6e06e9c6e77cdf3df07 |
|
BLAKE2b-256 | 841270453d4a4965e11b37a94eb9ec813f092cc78a59a63d8c4cee78baf17882 |
Hashes for haveibeenpwned_asyncio-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7665d04f194fb98b112551d4d72f87d040d5b49d4cd3f85b245f06f7a6863e54 |
|
MD5 | 660bd82fce9ac36f69386d58011cfacd |
|
BLAKE2b-256 | 7f8c0a9e7efe3941423e80a645ebdca9c630b27d504e1d34f1ea88772c0156f4 |