~busykoala/pwned_api

API to check for pwned passwords.
b7e2af53 — Matthias Osswald 1 year, 26 days ago
Remove exception from output.
394790ae — Matthias Osswald 1 year, 8 months ago
Improve output and replace double ticks.
c9acb81b — Matthias Osswald 1 year, 8 months ago
Fix tests and index out of range error.

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~busykoala/pwned_api
read/write
git@git.sr.ht:~busykoala/pwned_api

You can also use your local clone with git send-email.

#Pwned API

#Installation

git clone git@git.sr.ht:~busykoala/pwned_api
cd pwned_api
python3 -m venv .
source ./bin/activate
pip install -e .

To finish the setup move the textfile to projectroot/passwords.txt. The file should look like this (with newline instead of \n):

7C4A8D09CA3762AF61E59520943DC26494F8941B:23547453\n
7C4A8D09CA3762AF61E59520943DC26494F8941B:23547453\n

Therefore each line contains a sha1 hash and the number of occurences. Also see https://haveibeenpwned.com/Passwords as a reference.

Execute python app/insert_to_db.py to insert them into the DB.

#Run

# development mode
python app/__init__.py

# deployment mode (create service with command)
gunicorn app:init_app --bind 0.0.0.0:8081 --worker-class aiohttp.GunicornWebWorker

#Test

source ./bin/activate
pip install -e ".[test]"
python -m pytest --flake8

#Setup Postgres

>> CREATE DATABASE passwords
>> CREATE TABLE passwords (hash TEXT PRIMARY KEY, occurences INTEGER)
>> INSERT INTO passwords(hash, occurences) VALUES('5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8', 42);

>> pwned_api=# CREATE INDEX cluster_hash ON passwords (hash);
CREATE INDEX
>> pwned_api=# CLUSTER passwords USING cluster_hash;
CLUSTER