Skip to main content

Server validation library for the POW Captcha ecosystem.

Project description

powchallenge_server (Python)

A fully typed, robust Proof-of-Work (PoW) CAPTCHA server library for Python. This package provides the backend validation and challenge generation for the POW Captcha ecosystem. It prevents botnets, DDoS attacks, and credential stuffing by leveraging memory-hard cryptographic puzzles.

Features

  • Argon2id Powered: Defeats GPU and ASIC parallelism effectively.
  • Async IO Support: Designed for high performance and fast concurrency.
  • Storage Backends: Out-of-the-box support for internal Memory storage and Redis.
  • Framework Agnostic: Integrates beautifully with FastAPI, Starlette, Flask, or raw ASGI/WSGI applications.

Installation

Install using pip, poetry, or uv:

pip install powchallenge_server

How to Use

Here is a simple example integrating with FastAPI:

from fastapi import FastAPI, Request
from powchallenge_server import POWCaptchaServer
from powchallenge_server.interfaces import CaptchaValidatedPOW
from ipaddress import IPv4Address

app = FastAPI()

# Initialize server: Difficulty 10, 300 seconds validity, False for Memory Storage
captcha = POWCaptchaServer(10, 300, False)

@app.get("/challenge")
async def get_challenge(request: Request):
    ip = IPv4Address(request.client.host)
    challenge = await captcha.get_challenge(ip)
    return challenge

@app.post("/verify")
async def verify(payload: CaptchaValidatedPOW, request: Request):
    ip = IPv4Address(request.client.host)
    try:
        await captcha.verify_pow(payload, ip)
        return {"message": "Access Granted"}
    except Exception as e:
        return {"error": str(e)}

For advanced configuration, error handling, and Redis integration, please check the main documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

powchallenge_server-1.0.3.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

powchallenge_server-1.0.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file powchallenge_server-1.0.3.tar.gz.

File metadata

  • Download URL: powchallenge_server-1.0.3.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for powchallenge_server-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d1d260837089a5440878b819376d31e93ccbf8852f846940cbfb4528318674ba
MD5 58246ebd88de86afd578e62b6be5f40d
BLAKE2b-256 c0b243653fa14a7ac47de18761285511187ac6e4ae5ce3aa01b3054ba55cb6ea

See more details on using hashes here.

File details

Details for the file powchallenge_server-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for powchallenge_server-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 194d11caca971c18cec8fb6a7ca7432737741c6a34046e784cc10a35e81c60b9
MD5 695b0d8dd941250387c990cfc28fb943
BLAKE2b-256 25f5814495341f28ca8edec2d01397ee75dbe86ce900ad88fb70e09fb6962b1e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page