simple-module-auth 0.0.18__tar.gz → 0.0.20__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.
Files changed (26) hide show
  1. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/.gitignore +1 -0
  2. simple_module_auth-0.0.20/PKG-INFO +84 -0
  3. simple_module_auth-0.0.20/README.md +56 -0
  4. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/pyproject.toml +3 -3
  5. simple_module_auth-0.0.18/PKG-INFO +0 -71
  6. simple_module_auth-0.0.18/README.md +0 -43
  7. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/LICENSE +0 -0
  8. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/__init__.py +0 -0
  9. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/contracts/__init__.py +0 -0
  10. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/contracts/provider.py +0 -0
  11. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/contracts/resolver.py +0 -0
  12. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/contracts/schemas.py +0 -0
  13. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/deps.py +0 -0
  14. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/locales/en.json +0 -0
  15. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/locales/es.json +0 -0
  16. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/middleware.py +0 -0
  17. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/module.py +0 -0
  18. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/py.typed +0 -0
  19. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/auth/state.py +0 -0
  20. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/package.json +0 -0
  21. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/tests/test_auth_middleware.py +0 -0
  22. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/tests/test_auth_provider_protocol.py +0 -0
  23. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/tests/test_deps.py +0 -0
  24. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/tests/test_module.py +0 -0
  25. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/tests/test_resolver_registry.py +0 -0
  26. {simple_module_auth-0.0.18 → simple_module_auth-0.0.20}/tests/test_user_context.py +0 -0
@@ -61,3 +61,4 @@ Thumbs.db
61
61
  .playwright-mcp/*
62
62
  host/client_app/.playwright-cli/*
63
63
  .superpowers/
64
+ .qa/
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.4
2
+ Name: simple_module_auth
3
+ Version: 0.0.20
4
+ Summary: Session-cookie authentication primitives — middleware, login/logout, redirect helpers for simple_module
5
+ Project-URL: Homepage, https://github.com/antosubash/simple_module_python
6
+ Project-URL: Repository, https://github.com/antosubash/simple_module_python
7
+ Project-URL: Issues, https://github.com/antosubash/simple_module_python/issues
8
+ Project-URL: Changelog, https://github.com/antosubash/simple_module_python/blob/main/CHANGELOG.md
9
+ Author-email: Anto Subash <antosubash@live.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: authentication,cookie,fastapi,session,simple-module
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: FastAPI
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Internet :: WWW/HTTP
21
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.12
24
+ Requires-Dist: itsdangerous>=2.2
25
+ Requires-Dist: simple-module-core==0.0.20
26
+ Requires-Dist: simple-module-db==0.0.20
27
+ Description-Content-Type: text/markdown
28
+
29
+ # simple_module_auth
30
+
31
+ Pluggable authentication core for [simple_module](https://github.com/antosubash/simple_module_python) apps. Owns the stable public contracts every other module imports — `UserContext`, the `AuthProvider` protocol, the `PrincipalResolver` chain, and the `get_current_user` / `CurrentUser` / `require_permission` dependencies — plus the `AuthMiddleware` that resolves the current principal on every request.
32
+
33
+ **Heads up:** for most apps you don't install this directly — an auth-provider module (`simple_module_users` for email+password, `simple_module_keycloak` for OIDC) pulls it in and registers itself on `app.state.auth.auth_provider`.
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ pip install simple_module_auth
39
+ ```
40
+
41
+ ## What it provides
42
+
43
+ - `UserContext` — the request-scoped principal (`id`, `name`, `email`, `roles`).
44
+ - `AuthProvider` protocol — the swappable-backend contract (`resolve_user`, `get_login_url`, `get_logout_url`, `get_public_paths`, `is_bearer_request`); exactly one provider module registers an implementation on `app.state.auth.auth_provider`.
45
+ - `PrincipalResolver` chain — async `(Request) -> UserContext | None` callables apps append to `app.state.auth.principal_resolvers` (e.g. PAT/bearer-token or API-key auth), consulted after the session path.
46
+ - `AuthMiddleware` — delegates to the provider + resolver chain on every request and populates the request principal.
47
+ - `get_current_user` / `CurrentUser` dependency and the `require_permission(*permissions)` dependency factory.
48
+ - Anonymous-access is declared via the framework's method-aware `register_public_routes` hook (with the `SM_AUTH_PUBLIC_PATHS` host-level escape hatch).
49
+
50
+ ## Usage
51
+
52
+ ```python
53
+ from fastapi import APIRouter
54
+
55
+ from auth.deps import CurrentUser
56
+
57
+ router = APIRouter()
58
+
59
+
60
+ @router.get("/me")
61
+ async def me(user: CurrentUser):
62
+ return {"user_id": user.id, "email": user.email}
63
+ ```
64
+
65
+ Routes that need a specific permission use the `require_permission(...)` dependency factory:
66
+
67
+ ```python
68
+ from fastapi import Depends
69
+
70
+ from auth.deps import require_permission
71
+
72
+
73
+ @router.post("/", dependencies=[Depends(require_permission("products.create"))])
74
+ async def create_product(): ...
75
+ ```
76
+
77
+ ## Depends on
78
+
79
+ - `simple_module_core`, `simple_module_db`
80
+ - `itsdangerous`
81
+
82
+ ## License
83
+
84
+ MIT — see [LICENSE](https://github.com/antosubash/simple_module_python/blob/main/LICENSE).
@@ -0,0 +1,56 @@
1
+ # simple_module_auth
2
+
3
+ Pluggable authentication core for [simple_module](https://github.com/antosubash/simple_module_python) apps. Owns the stable public contracts every other module imports — `UserContext`, the `AuthProvider` protocol, the `PrincipalResolver` chain, and the `get_current_user` / `CurrentUser` / `require_permission` dependencies — plus the `AuthMiddleware` that resolves the current principal on every request.
4
+
5
+ **Heads up:** for most apps you don't install this directly — an auth-provider module (`simple_module_users` for email+password, `simple_module_keycloak` for OIDC) pulls it in and registers itself on `app.state.auth.auth_provider`.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install simple_module_auth
11
+ ```
12
+
13
+ ## What it provides
14
+
15
+ - `UserContext` — the request-scoped principal (`id`, `name`, `email`, `roles`).
16
+ - `AuthProvider` protocol — the swappable-backend contract (`resolve_user`, `get_login_url`, `get_logout_url`, `get_public_paths`, `is_bearer_request`); exactly one provider module registers an implementation on `app.state.auth.auth_provider`.
17
+ - `PrincipalResolver` chain — async `(Request) -> UserContext | None` callables apps append to `app.state.auth.principal_resolvers` (e.g. PAT/bearer-token or API-key auth), consulted after the session path.
18
+ - `AuthMiddleware` — delegates to the provider + resolver chain on every request and populates the request principal.
19
+ - `get_current_user` / `CurrentUser` dependency and the `require_permission(*permissions)` dependency factory.
20
+ - Anonymous-access is declared via the framework's method-aware `register_public_routes` hook (with the `SM_AUTH_PUBLIC_PATHS` host-level escape hatch).
21
+
22
+ ## Usage
23
+
24
+ ```python
25
+ from fastapi import APIRouter
26
+
27
+ from auth.deps import CurrentUser
28
+
29
+ router = APIRouter()
30
+
31
+
32
+ @router.get("/me")
33
+ async def me(user: CurrentUser):
34
+ return {"user_id": user.id, "email": user.email}
35
+ ```
36
+
37
+ Routes that need a specific permission use the `require_permission(...)` dependency factory:
38
+
39
+ ```python
40
+ from fastapi import Depends
41
+
42
+ from auth.deps import require_permission
43
+
44
+
45
+ @router.post("/", dependencies=[Depends(require_permission("products.create"))])
46
+ async def create_product(): ...
47
+ ```
48
+
49
+ ## Depends on
50
+
51
+ - `simple_module_core`, `simple_module_db`
52
+ - `itsdangerous`
53
+
54
+ ## License
55
+
56
+ MIT — see [LICENSE](https://github.com/antosubash/simple_module_python/blob/main/LICENSE).
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "simple_module_auth"
3
- version = "0.0.18"
3
+ version = "0.0.20"
4
4
  description = "Session-cookie authentication primitives — middleware, login/logout, redirect helpers for simple_module"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -22,8 +22,8 @@ classifiers = [
22
22
  ]
23
23
  dependencies = [
24
24
  "itsdangerous>=2.2",
25
- "simple_module_core==0.0.18",
26
- "simple_module_db==0.0.18",
25
+ "simple_module_core==0.0.20",
26
+ "simple_module_db==0.0.20",
27
27
  ]
28
28
 
29
29
  [project.entry-points.simple_module]
@@ -1,71 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: simple_module_auth
3
- Version: 0.0.18
4
- Summary: Session-cookie authentication primitives — middleware, login/logout, redirect helpers for simple_module
5
- Project-URL: Homepage, https://github.com/antosubash/simple_module_python
6
- Project-URL: Repository, https://github.com/antosubash/simple_module_python
7
- Project-URL: Issues, https://github.com/antosubash/simple_module_python/issues
8
- Project-URL: Changelog, https://github.com/antosubash/simple_module_python/blob/main/CHANGELOG.md
9
- Author-email: Anto Subash <antosubash@live.com>
10
- License-Expression: MIT
11
- License-File: LICENSE
12
- Keywords: authentication,cookie,fastapi,session,simple-module
13
- Classifier: Development Status :: 3 - Alpha
14
- Classifier: Framework :: FastAPI
15
- Classifier: Intended Audience :: Developers
16
- Classifier: License :: OSI Approved :: MIT License
17
- Classifier: Operating System :: OS Independent
18
- Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3.12
20
- Classifier: Topic :: Internet :: WWW/HTTP
21
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
- Classifier: Typing :: Typed
23
- Requires-Python: >=3.12
24
- Requires-Dist: itsdangerous>=2.2
25
- Requires-Dist: simple-module-core==0.0.18
26
- Requires-Dist: simple-module-db==0.0.18
27
- Description-Content-Type: text/markdown
28
-
29
- # simple_module_auth
30
-
31
- Session-cookie authentication primitives for [simple_module](https://github.com/antosubash/simple_module_python) apps. Provides the `SessionMiddleware` wiring, login/logout helpers, and login-redirect handling used by the `simple_module_users` module.
32
-
33
- **Heads up:** for most apps you don't install this directly — `simple_module_users` pulls it in and builds the email+password auth flow on top of these primitives.
34
-
35
- ## Install
36
-
37
- ```bash
38
- pip install simple_module_auth
39
- ```
40
-
41
- ## What it provides
42
-
43
- - Starlette `SessionMiddleware` configuration reading `SM_SECRET_KEY` and `SM_SESSION_COOKIE_*` env vars.
44
- - `current_user_id` FastAPI dependency reading the signed session cookie.
45
- - Redirect-to-login helpers for unauthenticated requests on Inertia routes.
46
- - Login-required decorator / dependency for protecting routes without pulling in the heavier `simple_module_users` package.
47
-
48
- ## Usage
49
-
50
- ```python
51
- from fastapi import APIRouter, Depends
52
- from simple_module_auth import require_login
53
-
54
- router = APIRouter()
55
-
56
-
57
- @router.get("/me")
58
- async def me(user_id: int = Depends(require_login)):
59
- return {"user_id": user_id}
60
- ```
61
-
62
- Routes that need more than just "logged in" (e.g. role/permission checks) should use `simple_module_permissions` instead.
63
-
64
- ## Depends on
65
-
66
- - `simple_module_core`, `simple_module_db`
67
- - `itsdangerous`
68
-
69
- ## License
70
-
71
- MIT — see [LICENSE](https://github.com/antosubash/simple_module_python/blob/main/LICENSE).
@@ -1,43 +0,0 @@
1
- # simple_module_auth
2
-
3
- Session-cookie authentication primitives for [simple_module](https://github.com/antosubash/simple_module_python) apps. Provides the `SessionMiddleware` wiring, login/logout helpers, and login-redirect handling used by the `simple_module_users` module.
4
-
5
- **Heads up:** for most apps you don't install this directly — `simple_module_users` pulls it in and builds the email+password auth flow on top of these primitives.
6
-
7
- ## Install
8
-
9
- ```bash
10
- pip install simple_module_auth
11
- ```
12
-
13
- ## What it provides
14
-
15
- - Starlette `SessionMiddleware` configuration reading `SM_SECRET_KEY` and `SM_SESSION_COOKIE_*` env vars.
16
- - `current_user_id` FastAPI dependency reading the signed session cookie.
17
- - Redirect-to-login helpers for unauthenticated requests on Inertia routes.
18
- - Login-required decorator / dependency for protecting routes without pulling in the heavier `simple_module_users` package.
19
-
20
- ## Usage
21
-
22
- ```python
23
- from fastapi import APIRouter, Depends
24
- from simple_module_auth import require_login
25
-
26
- router = APIRouter()
27
-
28
-
29
- @router.get("/me")
30
- async def me(user_id: int = Depends(require_login)):
31
- return {"user_id": user_id}
32
- ```
33
-
34
- Routes that need more than just "logged in" (e.g. role/permission checks) should use `simple_module_permissions` instead.
35
-
36
- ## Depends on
37
-
38
- - `simple_module_core`, `simple_module_db`
39
- - `itsdangerous`
40
-
41
- ## License
42
-
43
- MIT — see [LICENSE](https://github.com/antosubash/simple_module_python/blob/main/LICENSE).