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.0.tar.gz (11.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.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: powchallenge_server-1.0.0.tar.gz
  • Upload date:
  • Size: 11.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.0.tar.gz
Algorithm Hash digest
SHA256 259366dbfe2201e34b9c6ade0de407cf50f7d261012e13b06864188483ade202
MD5 c6fa7ab3b1b010f8eb0655c5e02190aa
BLAKE2b-256 c7387e53a13ac818dc05e5249a13cbc646d280feb5814bea0ffb201923173335

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for powchallenge_server-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fa793bc8f66f84edb6d68421711e5895f4f6afb077a5f81e2fe2321208d12d8
MD5 57e1d6635dc01fcdfd7b806d3b895d87
BLAKE2b-256 8fea4c9dd3974594be26e43e60b9c0f50b8f47a77381e91b9f7a4114c46af969

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