fastapi-better-auth-bridge 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mulugeta Solomon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: fastapi-better-auth-bridge
3
+ Version: 0.0.1
4
+ Summary: Verify Better Auth (TypeScript) sessions from FastAPI. A bridge, not a Python port.
5
+ Keywords: better-auth,fastapi,authentication,session,jwt,jwks
6
+ Author: Mulugeta Solomon
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 1 - Planning
10
+ Classifier: Framework :: FastAPI
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Internet :: WWW/HTTP :: Session
18
+ Classifier: Topic :: Security
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.10
21
+ Project-URL: Homepage, https://github.com/Mulugeta-Solomon/fastapi-better-auth
22
+ Project-URL: Repository, https://github.com/Mulugeta-Solomon/fastapi-better-auth
23
+ Project-URL: Issues, https://github.com/Mulugeta-Solomon/fastapi-better-auth/issues
24
+ Description-Content-Type: text/markdown
25
+
26
+ # fastapi-better-auth-bridge
27
+
28
+ **A bridge to a TypeScript [Better Auth](https://better-auth.com) server — not a Python port.**
29
+ (If you want a full Python re-implementation, this is not it.) Community-maintained; not affiliated
30
+ with or endorsed by Better Auth.
31
+
32
+ > **Status: placeholder release (0.0.1).** The library is in active development — 0.1.0 is the first
33
+ > usable release. Watch the [repository](https://github.com/Mulugeta-Solomon/fastapi-better-auth)
34
+ > for progress. The distribution is `fastapi-better-auth-bridge` (the shorter spelling collides
35
+ > with an unrelated package under PyPI's name-similarity rules); the import is `fastapi_better_auth`.
36
+
37
+ ## What this will be
38
+
39
+ Better Auth is TypeScript-only: sign-in/up, OAuth, and 2FA run on your Node service. This package
40
+ makes its sessions first-class in FastAPI — verified correctly, with the traps handled:
41
+
42
+ | Mode | How | Revocation lag |
43
+ |---|---|---|
44
+ | **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 |
45
+ | **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) |
46
+ | **C — Remote get-session** | Forward the credential to `GET /api/auth/get-session` with fail-closed semantics | Instant |
47
+
48
+ All three behind one FastAPI-native surface:
49
+
50
+ ```python
51
+ # Planned 0.1 API — subject to change until 0.1.0 ships
52
+ auth = BetterAuth(verifiers=[JwtVerifier(base_url="https://auth.example.com")])
53
+ CurrentSession = Annotated[Session[MyUser], Depends(auth.current_session(user_model=MyUser))]
54
+
55
+ @app.get("/me")
56
+ async def me(session: CurrentSession) -> MyUser:
57
+ return session.user
58
+ ```
59
+
60
+ Design commitments: fail-closed everywhere; CSRF ships in the same release as cookie mode;
61
+ compatibility with Better Auth is **tested in CI against a real Node server**, never assumed.
62
+
63
+ ## Why a library instead of the snippet
64
+
65
+ The hand-rolled verifier circulating in Better Auth issues splits the cookie on the wrong dot,
66
+ misses the `__Secure-` name, compares HMACs non-constant-time, and never enforces `expiresAt`
67
+ (upstream's `findSession` doesn't either — the route layer does, so a bare DB join honors expired
68
+ sessions forever). This package exists to own those details, with conformance tests pinning them
69
+ to real Better Auth releases.
70
+
71
+ ## License
72
+
73
+ MIT © Mulugeta Solomon
@@ -0,0 +1,48 @@
1
+ # fastapi-better-auth-bridge
2
+
3
+ **A bridge to a TypeScript [Better Auth](https://better-auth.com) server — not a Python port.**
4
+ (If you want a full Python re-implementation, this is not it.) Community-maintained; not affiliated
5
+ with or endorsed by Better Auth.
6
+
7
+ > **Status: placeholder release (0.0.1).** The library is in active development — 0.1.0 is the first
8
+ > usable release. Watch the [repository](https://github.com/Mulugeta-Solomon/fastapi-better-auth)
9
+ > for progress. The distribution is `fastapi-better-auth-bridge` (the shorter spelling collides
10
+ > with an unrelated package under PyPI's name-similarity rules); the import is `fastapi_better_auth`.
11
+
12
+ ## What this will be
13
+
14
+ Better Auth is TypeScript-only: sign-in/up, OAuth, and 2FA run on your Node service. This package
15
+ makes its sessions first-class in FastAPI — verified correctly, with the traps handled:
16
+
17
+ | Mode | How | Revocation lag |
18
+ |---|---|---|
19
+ | **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 |
20
+ | **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) |
21
+ | **C — Remote get-session** | Forward the credential to `GET /api/auth/get-session` with fail-closed semantics | Instant |
22
+
23
+ All three behind one FastAPI-native surface:
24
+
25
+ ```python
26
+ # Planned 0.1 API — subject to change until 0.1.0 ships
27
+ auth = BetterAuth(verifiers=[JwtVerifier(base_url="https://auth.example.com")])
28
+ CurrentSession = Annotated[Session[MyUser], Depends(auth.current_session(user_model=MyUser))]
29
+
30
+ @app.get("/me")
31
+ async def me(session: CurrentSession) -> MyUser:
32
+ return session.user
33
+ ```
34
+
35
+ Design commitments: fail-closed everywhere; CSRF ships in the same release as cookie mode;
36
+ compatibility with Better Auth is **tested in CI against a real Node server**, never assumed.
37
+
38
+ ## Why a library instead of the snippet
39
+
40
+ The hand-rolled verifier circulating in Better Auth issues splits the cookie on the wrong dot,
41
+ misses the `__Secure-` name, compares HMACs non-constant-time, and never enforces `expiresAt`
42
+ (upstream's `findSession` doesn't either — the route layer does, so a bare DB join honors expired
43
+ sessions forever). This package exists to own those details, with conformance tests pinning them
44
+ to real Better Auth releases.
45
+
46
+ ## License
47
+
48
+ MIT © Mulugeta Solomon
@@ -0,0 +1,51 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.11,<0.13"]
3
+ build-backend = "uv_build"
4
+
5
+ [tool.uv.build-backend]
6
+ module-name = "fastapi_better_auth"
7
+
8
+ [project]
9
+ name = "fastapi-better-auth-bridge"
10
+ version = "0.0.1"
11
+ description = "Verify Better Auth (TypeScript) sessions from FastAPI. A bridge, not a Python port."
12
+ readme = "README.md"
13
+ requires-python = ">=3.10"
14
+ license = "MIT"
15
+ license-files = ["LICENSE"]
16
+ keywords = [
17
+ "better-auth",
18
+ "fastapi",
19
+ "authentication",
20
+ "session",
21
+ "jwt",
22
+ "jwks",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 1 - Planning",
26
+ "Framework :: FastAPI",
27
+ "Intended Audience :: Developers",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Topic :: Internet :: WWW/HTTP :: Session",
34
+ "Topic :: Security",
35
+ "Typing :: Typed",
36
+ ]
37
+ dependencies = []
38
+
39
+ [[project.authors]]
40
+ name = "Mulugeta Solomon"
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/Mulugeta-Solomon/fastapi-better-auth"
44
+ Repository = "https://github.com/Mulugeta-Solomon/fastapi-better-auth"
45
+ Issues = "https://github.com/Mulugeta-Solomon/fastapi-better-auth/issues"
46
+
47
+ [dependency-groups]
48
+ dev = [
49
+ "pytest>=8",
50
+ "ruff>=0.6",
51
+ ]
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.11,<0.13"]
3
+ build-backend = "uv_build"
4
+
5
+ [tool.uv.build-backend]
6
+ # Distribution name is fastapi-better-auth-bridge; the import package stays fastapi_better_auth.
7
+ module-name = "fastapi_better_auth"
8
+
9
+ [project]
10
+ name = "fastapi-better-auth-bridge"
11
+ version = "0.0.1"
12
+ description = "Verify Better Auth (TypeScript) sessions from FastAPI. A bridge, not a Python port."
13
+ readme = "README.md"
14
+ requires-python = ">=3.10"
15
+ license = "MIT"
16
+ license-files = ["LICENSE"]
17
+ authors = [{ name = "Mulugeta Solomon" }]
18
+ keywords = ["better-auth", "fastapi", "authentication", "session", "jwt", "jwks"]
19
+ classifiers = [
20
+ "Development Status :: 1 - Planning",
21
+ "Framework :: FastAPI",
22
+ "Intended Audience :: Developers",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Programming Language :: Python :: 3.13",
28
+ "Topic :: Internet :: WWW/HTTP :: Session",
29
+ "Topic :: Security",
30
+ "Typing :: Typed",
31
+ ]
32
+ dependencies = []
33
+
34
+ [dependency-groups]
35
+ dev = ["pytest>=8", "ruff>=0.6"]
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/Mulugeta-Solomon/fastapi-better-auth"
39
+ Repository = "https://github.com/Mulugeta-Solomon/fastapi-better-auth"
40
+ Issues = "https://github.com/Mulugeta-Solomon/fastapi-better-auth/issues"
@@ -0,0 +1,7 @@
1
+ """fastapi-better-auth-bridge: verify Better Auth sessions from FastAPI.
2
+
3
+ Placeholder release. The public API arrives in 0.1.0.
4
+ See https://github.com/Mulugeta-Solomon/fastapi-better-auth for status.
5
+ """
6
+
7
+ __version__ = "0.0.1"