Skip to main content

pyrx-auth-sdk

SDK for PYRX ecosystem services to integrate with pyrx.auth centralized authentication.

Installation

pip install pyrx-auth-sdk

# With FastAPI dependency support
pip install pyrx-auth-sdk[fastapi]

Features

  • JWT Verification: ES256 JWT verification with JWKS caching (no network per request)
  • FastAPI Dependency: get_current_user() extracts AuthenticatedUser from Bearer JWT
  • Event Consumer: Redis Stream consumer for user lifecycle events
  • Internal API Client: Service-to-service user lookup API

Quick Start

FastAPI Integration

from pyrx_auth_sdk.config import AuthSDKConfig
from pyrx_auth_sdk.dependencies import init_auth, get_current_user
from pyrx_auth_sdk.schemas import AuthenticatedUser

# At app startup
config = AuthSDKConfig(
    jwks_url="http://pyrx-auth:8001/api/v1/.well-known/jwks.json",
    issuer="pyrx.auth",
    audience="pyrx-mentor",
)
init_auth(config)

# In route handlers
@app.get("/protected")
async def protected(user: AuthenticatedUser = Depends(get_current_user)):
    print(f"User {user.id} from tenant {user.tenant_id}")

Event Consumer

from pyrx_auth_sdk.events import UserEventConsumer

consumer = UserEventConsumer(
    redis=redis_client,
    group_name="my-service-group",
    consumer_name="worker-1",
)

async def on_user_registered(payload):
    print(f"New user: {payload['user_id']}")

consumer.on("user.registered", on_user_registered)
await consumer.run()

Internal API Client

from pyrx_auth_sdk import AuthInternalClient
from pyrx_auth_sdk.config import AuthSDKConfig

client = AuthInternalClient(AuthSDKConfig(
    internal_api_url="http://pyrx-auth:8001",
    internal_api_key="your-service-key",
))

user = await client.get_user(user_id)
users, not_found = await client.get_users_batch(["uuid-1", "uuid-2"])

Environment Variables

Variable Description
PYRX_AUTH_JWKS_URL JWKS endpoint URL
PYRX_AUTH_ISSUER JWT issuer (default: pyrx.auth)
PYRX_AUTH_AUDIENCE JWT audience (your service slug)
PYRX_AUTH_INTERNAL_API_URL pyrx.auth base URL
PYRX_AUTH_INTERNAL_API_KEY Service-to-service API key

Metadata

Release files for pyrx-auth-sdk 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyrx-auth-sdk 0.1.1
File Size Uploaded Provenance
pyrx_auth_sdk-0.1.1.tar.gz 7.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyrx-auth-sdk 0.1.1
File Interpreter ABI Platform
pyrx_auth_sdk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / pyrx_auth_sdk-0.1.1.tar.gz

Download URL pyrx_auth_sdk-0.1.1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dfff5e25d39923b6bb4760b1b3fa3a109a1b1ea4ae92cdbcf91674931e178c01
BLAKE2b-256 checksum
How to use checksums
d106c483b1cd25c699a14b6b73c429ec81ea414675d4a76741ed19f386925acf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / pyrx_auth_sdk-0.1.1-py3-none-any.whl

Download URL pyrx_auth_sdk-0.1.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90c4998ddf1d20adc3ebb79a878a20d9c8fb1e00a914f7682068f01944554133
BLAKE2b-256 checksum
How to use checksums
bc8fe47733ad4df93d75943be5176ec3721735443b99ec267d201223428fc9ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for pyrx-auth-sdk 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page