Skip to main content

Python bindings for ProxyAuth authentication via Rust

Project description

PyProxyAuth


A lightweight Python library to authenticate and retrieve tokens via ProxyAuth.

install

pip install ppauth

usage

import ppauth

ppauth.auth(
    host="127.0.0.1", port=8080,
    username="admin", password="admin123",
    
    # Optional TOTP code (used if two-factor authentication is enabled).
    # Note: If using TOTP, the server should issue a token with a minimum 1-day expiration.
    # As a developer, you should provide a new TOTP code each time the token expires.
    totp="56845",
    
    timezone="Europe/Paris" 
)

token = ppauth.token()
token = ppauth.token(renew=True) # Automatically re-authenticates and returns a new token if the previous one has expired.
lease_token = ppauth.lease_token()

print({"token": token, "expire_at": lease_token})

# result
# {"expire_at": 16500,"token":"ZoHAauGmCyxjq6+1sfVbqy..."}

# for easy use method GET
# Use the route defined in routes.yml within your backend delivery. 
# You don't need to manually include the token in the headers it's handled automatically
headers = {"user-agent": "ppauth/0.1.1"}
params = {"params_key": "my_send_request_params_via_get"}

ppauth.get(
    "/app",          # The API route (relative path) to call on the authenticated backend
    headers=headers, # Optional custom HTTP headers (Python dict), e.g. {"X-User": "admin"}
    params=params,   # Optional query parameters (Python dict), e.g. {"limit": "10"}
    verify=False,    # Disable TLS certificate verification (useful for self-signed certs)
    timeout=5,       # Max duration (in seconds) to wait for a response before failing
    retry=5          # Number of retry attempts if the request fails (timeout or server error)
)

# result
# 'ok'

# you are similar for POST method
headers = {"user-agent": "ppauth/0.1.1"}
body = {"body_key": "my_send_request_data_via_post"}
json = {"json_key": "my_send_request_json_data_via_post"}

ppauth.post(
    "/app",          # The API route (relative path) to call on the authenticated backend
    headers=headers, # Optional custom HTTP headers (Python dict), e.g. {"Content-Type": "application/json"}
    body=body,       # (If implemented) Optional raw body content (usually a string or bytes)
    json=json,       # Optional JSON body (Python dict) that will be serialized and sent as application/json
    timeout=5,       # Max duration (in seconds) to wait for a response before raising a timeout error
    verify=False,    # Disable TLS certificate verification (useful for self-signed certificates)
    retry=2          # Number of retry attempts if the request fails (e.g., timeout or 5xx server errors)
)

# result
# 'ok'

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

ppauth-0.1.9-cp313-abi3-manylinux_2_34_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.34+ x86-64

ppauth-0.1.9-cp312-abi3-manylinux_2_34_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.34+ x86-64

ppauth-0.1.9-cp311-abi3-manylinux_2_34_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ x86-64

ppauth-0.1.9-cp310-abi3-manylinux_2_34_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

ppauth-0.1.9-cp39-abi3-manylinux_2_34_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

ppauth-0.1.9-cp38-abi3-manylinux_2_34_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.34+ x86-64

ppauth-0.1.9-cp37-abi3-manylinux_2_34_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.34+ x86-64

File details

Details for the file ppauth-0.1.9-cp313-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ppauth-0.1.9-cp313-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 597ea198dc37d02e8fff68eec17bfc4b213ae3a88d7d76fd894c537516d4efdc
MD5 3bd22955be9f82943c8d4874b904ec79
BLAKE2b-256 9a7a7cd41bb277c399e8ec55dccf9cce028b08746309def5881e49c46e0fdce5

See more details on using hashes here.

File details

Details for the file ppauth-0.1.9-cp312-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ppauth-0.1.9-cp312-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5fab9d6c0736d26a9ae421550563cb7b6d1f45048f8bcfdcc6baa8a9629fbd26
MD5 8a13c096fab66cc649b4e50936c871c5
BLAKE2b-256 bc374a54395e9c93b68970aa226d41d9b0e73575fb39eb298d5d1aa25527eb9d

See more details on using hashes here.

File details

Details for the file ppauth-0.1.9-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ppauth-0.1.9-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 abdccb24d3189d03fc9e286728cb94fb37ee1ecd63fae19d80eb7021e27b19d0
MD5 4c36b69859bcd135652f1d868f96de1b
BLAKE2b-256 10cc34b2429d4e754ca4f7ace6f1bfd3f60ab656523b5acab285747a139c8bbe

See more details on using hashes here.

File details

Details for the file ppauth-0.1.9-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ppauth-0.1.9-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c6de682a3fdff7af616549fad124d84c93d756ca6a9755bcf0073fe2d3866930
MD5 8acfd657df2f73d3c7ee9f321aba3f8c
BLAKE2b-256 c7003be8127e7097b33245f30917d1e8395a35d18b565918c920b70e9b95a27e

See more details on using hashes here.

File details

Details for the file ppauth-0.1.9-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ppauth-0.1.9-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9fea9827affc7cc678fd2fb3f6bd3e7b34d7c0be649e9ff77a6146231317456c
MD5 4a94ae04d6926a38ec53fa6071834271
BLAKE2b-256 f6c968fcb98f82cb06442b633454b82e84a1e008f5ee690b709d0b7808463299

See more details on using hashes here.

File details

Details for the file ppauth-0.1.9-cp38-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ppauth-0.1.9-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7e30e72b9764603183c8257c4d13a823a4cb2133724f95c34ece7a256c8299e7
MD5 7166ef9d710cb4b1143256e12110b4ae
BLAKE2b-256 98361161b19c4d71808d21ab08af24248e55c7bb89808af8b4a41ef85921bf14

See more details on using hashes here.

File details

Details for the file ppauth-0.1.9-cp37-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ppauth-0.1.9-cp37-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 72cfbf90fb2fd42ec5e62126f20b22c37c975ef0ddb169291987fb1c212d373b
MD5 74418c086bba63565eae3797a9cf69a5
BLAKE2b-256 aa3285e1338c9ca24017916ef9b6c5d4ab571aebaafc18992207a641b9bbe99c

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