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')
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 Distributions
Hashes for haveibeenpwned-asyncio-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b5db7f8549f8c6cca10ce0cc2cc9886a6b72951312a34f47e68372bf270a37e |
|
MD5 | a516083d0fa427640c0fbdb3e912033d |
|
BLAKE2b-256 | 8ff2427bcfece38a22051c9e2fbcd25b5900eab5e8461d057c3801c80e60c741 |
Hashes for haveibeenpwned_asyncio-0.0.1-py3.9.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca952ef6ab805ec6d90e07b4125665bec58ff58164187fe28fb93900d32aef05 |
|
MD5 | 4d23c17295bc23e18ba5c05741a81f4b |
|
BLAKE2b-256 | 75bfdf0ef4baf8c3610420fa6c254c655ca36b076e82f095c96090b7c69abe17 |
Hashes for haveibeenpwned_asyncio-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 733335e40daa3818e34c0b2c4ab84ccfcc1927c93810e34adfa77cd9d3a9dcdd |
|
MD5 | beafdfb9f0d1c83bea16e7a475f95add |
|
BLAKE2b-256 | 85abce86a56ec09336dea5f007b41a8ff442d0b6c17dd465bd13f40212dcf5d1 |