tba-router-session-login 0.4.0.dev2__py3-none-any.whl

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,19 @@
1
+ """Interactive session-login HTTP carrier."""
2
+
3
+ from .binding import (
4
+ CredsIn,
5
+ DatabaseDependency,
6
+ LoginRequestTarget,
7
+ RequiredPasswordChangeIn,
8
+ build_login_router,
9
+ include_login_endpoint,
10
+ )
11
+
12
+ __all__ = [
13
+ "CredsIn",
14
+ "DatabaseDependency",
15
+ "LoginRequestTarget",
16
+ "RequiredPasswordChangeIn",
17
+ "build_login_router",
18
+ "include_login_endpoint",
19
+ ]
@@ -0,0 +1,97 @@
1
+ """HTTP carrier binding for interactive identity session login."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Awaitable, Callable
6
+ from typing import Any, TypeAlias
7
+
8
+ from pydantic import BaseModel, constr
9
+ from tigrbl import Depends, Request, TigrblApp, TigrblRouter
10
+ from tba_protocol_oauth.schemas import TokenPair
11
+
12
+
13
+ class CredsIn(BaseModel):
14
+ identifier: constr(strip_whitespace=True, min_length=3, max_length=120)
15
+ password: constr(min_length=8, max_length=256)
16
+
17
+
18
+ class RequiredPasswordChangeIn(BaseModel):
19
+ current_password: constr(min_length=8, max_length=256)
20
+ new_password: constr(min_length=8, max_length=256)
21
+
22
+
23
+ DatabaseDependency: TypeAlias = Callable[..., object]
24
+ LoginRequestTarget: TypeAlias = Callable[..., Any | Awaitable[Any]]
25
+
26
+
27
+ def build_login_router(
28
+ *,
29
+ login_request: LoginRequestTarget,
30
+ get_db: DatabaseDependency,
31
+ required_password_change_request: LoginRequestTarget | None = None,
32
+ ) -> TigrblRouter:
33
+ """Build the POST login carrier around injected runtime orchestration."""
34
+
35
+ router = TigrblRouter()
36
+
37
+ @router.route("/login", methods=["POST"], response_model=TokenPair)
38
+ async def login(
39
+ request: Request,
40
+ creds: CredsIn | None = None,
41
+ db: object = Depends(get_db),
42
+ ) -> Any:
43
+ if creds is None:
44
+ creds = CredsIn.model_validate(await request.json() or {})
45
+ return await login_request(
46
+ request=request,
47
+ db=db,
48
+ identifier=creds.identifier,
49
+ password=creds.password,
50
+ )
51
+
52
+ if required_password_change_request is not None:
53
+ @router.route("/login/password-change", methods=["POST"])
54
+ async def required_password_change(
55
+ request: Request,
56
+ payload: RequiredPasswordChangeIn | None = None,
57
+ db: object = Depends(get_db),
58
+ ) -> Any:
59
+ if payload is None:
60
+ payload = RequiredPasswordChangeIn.model_validate(
61
+ await request.json() or {}
62
+ )
63
+ return await required_password_change_request(
64
+ request=request,
65
+ db=db,
66
+ current_password=payload.current_password,
67
+ new_password=payload.new_password,
68
+ )
69
+
70
+ return router
71
+
72
+
73
+ def include_login_endpoint(
74
+ app: TigrblApp,
75
+ router: TigrblRouter,
76
+ *,
77
+ enabled: bool = True,
78
+ ) -> None:
79
+ """Mount the login carrier once when selected by composition."""
80
+
81
+ routes = getattr(getattr(app, "router", None), "routes", ())
82
+ if enabled and not any(
83
+ (getattr(route, "path", None) or getattr(route, "path_template", None))
84
+ == "/login"
85
+ for route in routes
86
+ ):
87
+ app.include_router(router)
88
+
89
+
90
+ __all__ = [
91
+ "CredsIn",
92
+ "DatabaseDependency",
93
+ "LoginRequestTarget",
94
+ "RequiredPasswordChangeIn",
95
+ "build_login_router",
96
+ "include_login_endpoint",
97
+ ]
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561 typed-package discovery.
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.4
2
+ Name: tba-router-session-login
3
+ Version: 0.4.0.dev2
4
+ Summary: HTTP carrier binding for interactive identity session login.
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.10,<3.15
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Requires-Dist: pydantic (>=2.0)
14
+ Requires-Dist: tba-protocol-oauth (==0.4.0.dev2)
15
+ Requires-Dist: tigrbl (==0.4.5.dev8)
16
+ Description-Content-Type: text/markdown
17
+
18
+ # tba-router-session-login
19
+
20
+ HTTP carrier binding for interactive username/password session login.
21
+
22
+ This package owns the credential request schema, POST route, and dependency
23
+ materialization. Authentication, session creation, token issuance, cookies,
24
+ audit, and durability are injected by runtime composition.
25
+
@@ -0,0 +1,6 @@
1
+ tba_router_session_login/__init__.py,sha256=fb9d3TACi7xlgGgCGLSFu8bFdqzPntHRChc1FN0bErE,385
2
+ tba_router_session_login/binding.py,sha256=Xp1XfGZ2ZLaHCY_SoYCwK5KlY54QSfiFDDECTQAXXaw,2916
3
+ tba_router_session_login/py.typed,sha256=RriHiC6lbKUoB0lG-HLnxVlO_73PQ5h-MiTyy6m1THA,51
4
+ tba_router_session_login-0.4.0.dev2.dist-info/METADATA,sha256=SVUWj4ql5CwNE71ScAtRm5LfX4etveI-VhAA55LqDkc,977
5
+ tba_router_session_login-0.4.0.dev2.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
6
+ tba_router_session_login-0.4.0.dev2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.5.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any