Skip to main content

fastapi-better-auth-bridge

A bridge to a TypeScript Better Auth server — not a Python port. (If you want a full Python re-implementation, this is not it.) Community-maintained; not affiliated with or endorsed by Better Auth.

Status: placeholder release (0.0.1). The library is in active development — 0.1.0 is the first usable release. Watch the repository for progress. The distribution is fastapi-better-auth-bridge (the shorter spelling collides with an unrelated package under PyPI's name-similarity rules); the import is fastapi_better_auth.

What this will be

Better Auth is TypeScript-only: sign-in/up, OAuth, and 2FA run on your Node service. This package makes its sessions first-class in FastAPI — verified correctly, with the traps handled:

Mode How Revocation lag
A — Cookie + shared DB/Redis Verify the signed session_token cookie (HMAC-SHA256, exact wire parity with better-call) and read the session store directly Instant
B — JWT / JWKS Verify Better Auth JWT-plugin tokens statelessly against /api/auth/jwks (EdDSA by default, pinned allowlist, required claims) ≤ token lifetime (15 min default)
C — Remote get-session Forward the credential to GET /api/auth/get-session with fail-closed semantics Instant

All three behind one FastAPI-native surface:

# Planned 0.1 API — subject to change until 0.1.0 ships
auth = BetterAuth(verifiers=[JwtVerifier(base_url="https://auth.example.com")])
CurrentSession = Annotated[Session[MyUser], Depends(auth.current_session(user_model=MyUser))]

@app.get("/me")
async def me(session: CurrentSession) -> MyUser:
    return session.user

Design commitments: fail-closed everywhere; CSRF ships in the same release as cookie mode; compatibility with Better Auth is tested in CI against a real Node server, never assumed.

Why a library instead of the snippet

The hand-rolled verifier circulating in Better Auth issues splits the cookie on the wrong dot, misses the __Secure- name, compares HMACs non-constant-time, and never enforces expiresAt (upstream's findSession doesn't either — the route layer does, so a bare DB join honors expired sessions forever). This package exists to own those details, with conformance tests pinning them to real Better Auth releases.

License

MIT © Mulugeta Solomon

Release files for fastapi-better-auth-bridge 0.0.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 fastapi-better-auth-bridge 0.0.1
File Size Uploaded
fastapi_better_auth_bridge-0.0.1.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-better-auth-bridge 0.0.1
File Interpreter ABI Platform
fastapi_better_auth_bridge-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / fastapi_better_auth_bridge-0.0.1.tar.gz

Download URL fastapi_better_auth_bridge-0.0.1.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d8a3d65d3a0275b7b5bfdc61a04ac3a674694d7b51fcd76f9ed8594bbbb79dd5
BLAKE2b-256 checksum
How to use checksums
650098bef1725b5d8a4ecdc377fe771830a98e13a3a7dd21b138df9ebc6e7b80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.

Transparency log

Release files / fastapi_better_auth_bridge-0.0.1-py3-none-any.whl

Download URL fastapi_better_auth_bridge-0.0.1-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed4d553108d380e7a790bbd93c3eebe0d6b8dc5a71318978293a382f322f1e44
BLAKE2b-256 checksum
How to use checksums
668e42d4bf4198a233d76000491000e7c0e2faf410854edb744fbb5f3065ff79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.1.0

2 release files

This release

0.0.1 This release

2 release files

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