This release is a pre-release and may not be stable for production use.
Buwigs Auth Python SDK
Version 0.2.0a1 · alpha · Python 3.10+
This package provides OIDC client and resource-server helpers for Python
applications. It validates Buwigs Auth tokens and returns an immutable
(issuer, subject) principal. Your application remains responsible for
mapping that identity to its own account, tenant, and permissions.
Install
pip install buwigs-auth-sdk==0.2.0a1
FastAPI support is optional:
pip install 'buwigs-auth-sdk[fastapi]'
Authorization Code + PKCE
Create a client with the exact issuer, client ID, API audience, and registered redirect URI. Store state, nonce, and the PKCE verifier in a short-lived, server-side transaction bound to the browser session. Consume the transaction once in the callback.
from buwigs_auth_sdk import OidcClient
oidc = OidcClient(
issuer="https://auth.buwigs.com/realms/buwigs-local",
client_id="your-registered-client-id",
api_audience="your-api-audience",
redirect_uri="https://app.example.com/auth/callback",
)
transaction = oidc.authorization_request()
# Save transaction state, nonce, and verifier server-side before redirecting.
At the callback, validate state, exchange the code, validate the ID token and nonce, then establish your application's session:
oidc.validate_state(saved_state, returned_state)
tokens = oidc.exchange_code(code, saved_verifier, client_secret=server_secret)
principal = oidc.verify_id_token(tokens["id_token"], expected_nonce=saved_nonce)
api_principal = oidc.verify_access_token(tokens["access_token"])
Only use client_secret in a trusted server process. Never send it to browser
or Electron code. Public clients must not have a client secret. Validate the
ID token before creating an application session and validate access tokens on
each protected resource request.
FastAPI resource-server validation
from fastapi import Depends, FastAPI
from buwigs_auth_sdk import OidcClient, Principal
from buwigs_auth_sdk.fastapi import principal_dependency
oidc = OidcClient(
issuer="https://auth.buwigs.com/realms/buwigs-local",
client_id="your-client-id",
api_audience="your-api-audience",
redirect_uri="https://app.example.com/auth/callback",
)
require_principal = principal_dependency(oidc)
app = FastAPI()
@app.get("/api/me")
def me(principal: Principal = Depends(require_principal)):
# Resolve subject in this application's own database and authorize there.
return {"auth_subject": principal.subject}
The dependency validates a Bearer access token against the configured issuer, RS256 signing keys, and API audience. It returns a generic unauthorized response for missing or invalid tokens. It does not assign application roles.
Other OIDC helpers
The client also provides refresh-token exchange, token revocation, UserInfo subject checking, and an RP-initiated logout URL. Persist rotated refresh tokens atomically in your server-side session store. The SDK does not store tokens, create sessions, or implement a login UI.
Security and support
- Use HTTPS issuer and redirect URLs in deployed applications.
- Bind state, nonce, and PKCE verifier to one browser transaction and consume them once.
- Keep confidential client credentials in backend secret storage.
- Do not accept identity claims or roles from request bodies.
- Do not use email or phone as a substitute for the immutable subject.
- Pin the package version and review release notes before upgrading.
The service URL is the intended Buwigs issuer; verify its discovery document and supported API version before integration. This alpha SDK is not a browser authentication/session SDK and does not imply a security audit or OIDC conformance certification.
License
This SDK source is licensed under Apache-2.0. See the bundled LICENSE and
NOTICE. Its runtime dependencies are distributed separately under their
respective licenses. The Buwigs Auth server is separate proprietary software.
Metadata
Release files for buwigs-auth-sdk 0.2.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| buwigs_auth_sdk-0.2.0a1.tar.gz | 11.9 kB | Without provenance | Details for buwigs_auth_sdk-0.2.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| buwigs_auth_sdk-0.2.0a1-py3-none-any.whl | Python 3 | none | any | Details for buwigs_auth_sdk-0.2.0a1-py3-none-any.whl |
Total release size: 25.7 kB
Release files / buwigs_auth_sdk-0.2.0a1.tar.gz
| Download URL | buwigs_auth_sdk-0.2.0a1.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b176042cb4c99bd35246e8f9c52c5bc48c43b89ba71f2f354c94f4703d312c26
|
|
BLAKE2b-256 checksum How to use checksums |
ae75c5dfffca8c6bd06480895357fd9a5163ce9a93a746d23a84b3a48a8edfad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / buwigs_auth_sdk-0.2.0a1-py3-none-any.whl
| Download URL | buwigs_auth_sdk-0.2.0a1-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5847a463ef07f91083e22594dd0775fa40e960eb65382444519494c033a5105c
|
|
BLAKE2b-256 checksum How to use checksums |
95a1c45c9cd95cad669f924ba6336d0722a6d92235e6c65064b0abe4f16e27b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for buwigs-auth-sdk 0.2.0a1
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.