simple-module-auth 0.0.43__tar.gz → 0.0.44__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.
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/PKG-INFO +6 -6
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/README.md +2 -2
- simple_module_auth-0.0.44/auth/constants.py +11 -0
- simple_module_auth-0.0.44/auth/core/__init__.py +1 -0
- simple_module_auth-0.0.44/auth/deps.py +11 -0
- simple_module_auth-0.0.44/auth/middleware.py +11 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/models.py +3 -1
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/module.py +2 -2
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/renewal.py +1 -1
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/renewal_outcomes.py +1 -1
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/session.py +1 -1
- simple_module_auth-0.0.44/auth/state.py +11 -0
- simple_module_auth-0.0.44/auth/web/__init__.py +5 -0
- {simple_module_auth-0.0.43/auth → simple_module_auth-0.0.44/auth/web}/middleware.py +3 -3
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/package.json +1 -1
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/pyproject.toml +4 -4
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/tests/conftest.py +1 -1
- simple_module_auth-0.0.43/tests/test_resolver_registry.py → simple_module_auth-0.0.44/tests/contracts/resolver/test_auth_resolver_registry.py +5 -5
- simple_module_auth-0.0.44/tests/core/audit/test_auth_audit_redaction.py +16 -0
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/authority}/test_auth_oidc_authority.py +8 -8
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/jwks}/test_auth_oidc_jwks_cache.py +2 -2
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/jwks}/test_auth_oidc_jwt_hardening.py +2 -2
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/renewal}/test_auth_oidc_outcome_migration.py +1 -1
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/tokens}/test_auth_oidc_tokens.py +2 -2
- simple_module_auth-0.0.43/tests/test_deps.py → simple_module_auth-0.0.44/tests/web/deps/test_auth_deps.py +1 -1
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/web/deps}/test_auth_permission_deprecation.py +4 -2
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/web/middleware}/test_auth_middleware.py +2 -2
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/web/middleware}/test_auth_next_target.py +2 -2
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/web/middleware}/test_auth_unknown_paths.py +3 -3
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/.gitignore +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/LICENSE +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/__init__.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/contracts/__init__.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/contracts/provider.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/contracts/resolver.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/contracts/schemas.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/contracts/tokens.py +0 -0
- {simple_module_auth-0.0.43/auth → simple_module_auth-0.0.44/auth/core}/constants.py +0 -0
- {simple_module_auth-0.0.43/auth → simple_module_auth-0.0.44/auth/core}/state.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/locales/de.json +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/locales/en.json +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/locales/es.json +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/__init__.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/claims.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/directory.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/jwks.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/persistence.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/tenant.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/tokens.py +0 -0
- {simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/py.typed +0 -0
- {simple_module_auth-0.0.43/auth → simple_module_auth-0.0.44/auth/web}/_route_match.py +0 -0
- {simple_module_auth-0.0.43/auth → simple_module_auth-0.0.44/auth/web}/deps.py +0 -0
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/contracts/provider}/test_auth_provider_protocol.py +0 -0
- /simple_module_auth-0.0.43/tests/test_user_context.py → /simple_module_auth-0.0.44/tests/contracts/schemas/test_auth_user_context.py +0 -0
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/contracts/tokens}/test_auth_parse_bearer.py +0 -0
- /simple_module_auth-0.0.43/tests/test_module.py → /simple_module_auth-0.0.44/tests/core/module/test_auth_module.py +0 -0
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/renewal}/test_auth_oidc_authority_outcomes.py +0 -0
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/renewal}/test_auth_oidc_concurrent_renewal.py +0 -0
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/renewal}/test_auth_oidc_outcome_logout.py +0 -0
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/session}/test_auth_oidc_shared_helpers.py +0 -0
- {simple_module_auth-0.0.43/tests → simple_module_auth-0.0.44/tests/oidc_common/session}/test_auth_oidc_sign_in.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_auth
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.44
|
|
4
4
|
Summary: Session-cookie authentication primitives — middleware, login/logout, redirect helpers for simple_module
|
|
5
5
|
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
@@ -25,9 +25,9 @@ Requires-Dist: cryptography>=42
|
|
|
25
25
|
Requires-Dist: httpx<0.29,>=0.27
|
|
26
26
|
Requires-Dist: itsdangerous<3,>=2.2
|
|
27
27
|
Requires-Dist: pyjwt[crypto]<3,>=2.8
|
|
28
|
-
Requires-Dist: simple-module-core==0.0.
|
|
29
|
-
Requires-Dist: simple-module-db==0.0.
|
|
30
|
-
Requires-Dist: simple-module-hosting==0.0.
|
|
28
|
+
Requires-Dist: simple-module-core==0.0.44
|
|
29
|
+
Requires-Dist: simple-module-db==0.0.44
|
|
30
|
+
Requires-Dist: simple-module-hosting==0.0.44
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
|
|
33
33
|
# simple_module_auth
|
|
@@ -57,7 +57,7 @@ pip install simple_module_auth
|
|
|
57
57
|
```python
|
|
58
58
|
from fastapi import APIRouter
|
|
59
59
|
|
|
60
|
-
from auth.deps import CurrentUser
|
|
60
|
+
from auth.web.deps import CurrentUser
|
|
61
61
|
|
|
62
62
|
router = APIRouter()
|
|
63
63
|
|
|
@@ -81,7 +81,7 @@ from .constants import PERM_PRODUCTS_CREATE
|
|
|
81
81
|
async def create_product(): ...
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
`auth.deps.require_permission` is deprecated and will be removed in **0.1.0**
|
|
84
|
+
`auth.web.deps.require_permission` is deprecated and will be removed in **0.1.0**
|
|
85
85
|
(#698). It retains its legacy any-of semantics, role-based admin bypass and cached
|
|
86
86
|
permission check. Migrate to `RequiresPermission(PERM_KEY)`; for several required
|
|
87
87
|
permissions, declare a dependency for each. Unlike the legacy helper,
|
|
@@ -25,7 +25,7 @@ pip install simple_module_auth
|
|
|
25
25
|
```python
|
|
26
26
|
from fastapi import APIRouter
|
|
27
27
|
|
|
28
|
-
from auth.deps import CurrentUser
|
|
28
|
+
from auth.web.deps import CurrentUser
|
|
29
29
|
|
|
30
30
|
router = APIRouter()
|
|
31
31
|
|
|
@@ -49,7 +49,7 @@ from .constants import PERM_PRODUCTS_CREATE
|
|
|
49
49
|
async def create_product(): ...
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
`auth.deps.require_permission` is deprecated and will be removed in **0.1.0**
|
|
52
|
+
`auth.web.deps.require_permission` is deprecated and will be removed in **0.1.0**
|
|
53
53
|
(#698). It retains its legacy any-of semantics, role-based admin bypass and cached
|
|
54
54
|
permission check. Migrate to `RequiresPermission(PERM_KEY)`; for several required
|
|
55
55
|
permissions, declare a dependency for each. Unlike the legacy helper,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`auth.core.constants`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("auth.constants", remove_in="0.0.46", use="auth.core.constants")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("auth.core.constants")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""What every auth feature builds on: browser session keys and the app.state.auth container."""
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`auth.web.deps`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("auth.deps", remove_in="0.0.46", use="auth.web.deps")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("auth.web.deps")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`auth.web.middleware`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("auth.middleware", remove_in="0.0.46", use="auth.web.middleware")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("auth.web.middleware")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Short-lived cross-worker outcomes for browser token renewal."""
|
|
2
2
|
|
|
3
|
-
from typing import Any
|
|
3
|
+
from typing import Any, ClassVar
|
|
4
4
|
|
|
5
5
|
from simple_module_db.base import create_module_base
|
|
6
6
|
from sqlalchemy import JSON, BigInteger
|
|
@@ -10,6 +10,8 @@ Base = create_module_base("auth")
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class RefreshOutcome(Base, table=True): # ty: ignore[unsupported-base]
|
|
13
|
+
__audit_redact_fields__: ClassVar[set[str]] = {"outcome_key", "lock_key", "session"}
|
|
14
|
+
|
|
13
15
|
__tablename__ = "auth_refresh_outcome"
|
|
14
16
|
|
|
15
17
|
# sha256(refresh key : identity : spent sealed token); not a session id.
|
|
@@ -41,13 +41,13 @@ class AuthModule(ModuleBase):
|
|
|
41
41
|
)
|
|
42
42
|
|
|
43
43
|
def register_settings(self, app: FastAPI) -> None:
|
|
44
|
-
from auth.state import AuthState
|
|
44
|
+
from auth.core.state import AuthState
|
|
45
45
|
|
|
46
46
|
app.state.auth = AuthState()
|
|
47
47
|
app.state.principal_serializer = _serialize_principal
|
|
48
48
|
|
|
49
49
|
def register_middleware(self, app: FastAPI) -> None:
|
|
50
|
-
from auth.middleware import AuthMiddleware
|
|
50
|
+
from auth.web.middleware import AuthMiddleware
|
|
51
51
|
|
|
52
52
|
app.add_middleware(AuthMiddleware)
|
|
53
53
|
|
|
@@ -10,8 +10,8 @@ import httpx
|
|
|
10
10
|
from simple_module_hosting.session import SESSION_EXPIRES_AT_KEY
|
|
11
11
|
from starlette.requests import Request
|
|
12
12
|
|
|
13
|
-
from auth.constants import REFRESH_RETRY_AFTER_SECONDS
|
|
14
13
|
from auth.contracts.schemas import UserContext
|
|
14
|
+
from auth.core.constants import REFRESH_RETRY_AFTER_SECONDS
|
|
15
15
|
from auth.oidc_common.renewal_outcomes import coordinated_refresh
|
|
16
16
|
from auth.oidc_common.session import SessionKeys
|
|
17
17
|
|
{simple_module_auth-0.0.43 → simple_module_auth-0.0.44}/auth/oidc_common/renewal_outcomes.py
RENAMED
|
@@ -15,8 +15,8 @@ from simple_module_hosting.session import SESSION_EXPIRES_AT_KEY
|
|
|
15
15
|
from sqlalchemy import delete, or_
|
|
16
16
|
from sqlmodel import col
|
|
17
17
|
|
|
18
|
-
from auth.constants import REFRESH_RETRY_AFTER_SECONDS, SESSION_AUTHORITY_KEY, SESSION_ID_KEY
|
|
19
18
|
from auth.contracts.schemas import UserContext
|
|
19
|
+
from auth.core.constants import REFRESH_RETRY_AFTER_SECONDS, SESSION_AUTHORITY_KEY, SESSION_ID_KEY
|
|
20
20
|
from auth.models import RefreshOutcome
|
|
21
21
|
from auth.oidc_common.session import SessionKeys
|
|
22
22
|
|
|
@@ -13,7 +13,7 @@ from simple_module_hosting.csrf import rotate_csrf_token
|
|
|
13
13
|
from simple_module_hosting.session import SESSION_EXPIRES_AT_KEY, sign_in_preserved_keys
|
|
14
14
|
from starlette.responses import RedirectResponse
|
|
15
15
|
|
|
16
|
-
from auth.constants import SESSION_AUTHORITY_KEY, SESSION_ID_KEY
|
|
16
|
+
from auth.core.constants import SESSION_AUTHORITY_KEY, SESSION_ID_KEY
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@dataclass(frozen=True)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Moved to :mod:`auth.core.state`; this alias goes in 0.0.46 (module layout)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from simple_module_core.deprecation import deprecated_module
|
|
9
|
+
|
|
10
|
+
deprecated_module("auth.state", remove_in="0.0.46", use="auth.core.state")
|
|
11
|
+
sys.modules[__name__] = importlib.import_module("auth.core.state")
|
|
@@ -15,17 +15,17 @@ from simple_module_core.app_state import get_openapi_url
|
|
|
15
15
|
from simple_module_core.redirect_safety import SESSION_NEXT_KEY, safe_next_or_none
|
|
16
16
|
from simple_module_db.listeners import current_user_id
|
|
17
17
|
from simple_module_hosting.inertia_deps import is_inertia_request
|
|
18
|
-
from simple_module_hosting.path_matching import matches_path
|
|
18
|
+
from simple_module_hosting.path_matching import matches_path, validated_prefixes
|
|
19
19
|
from simple_module_hosting.public_access import is_public as route_is_public
|
|
20
20
|
from starlette.requests import Request
|
|
21
21
|
from starlette.responses import JSONResponse, RedirectResponse
|
|
22
22
|
from starlette.types import ASGIApp, Receive, Scope, Send
|
|
23
23
|
|
|
24
|
-
from auth._route_match import route_exists
|
|
24
|
+
from auth.web._route_match import route_exists
|
|
25
25
|
|
|
26
26
|
logger = logging.getLogger(__name__)
|
|
27
27
|
|
|
28
|
-
_FRAMEWORK_PUBLIC_PREFIXES = (
|
|
28
|
+
_FRAMEWORK_PUBLIC_PREFIXES = validated_prefixes(
|
|
29
29
|
"/health/",
|
|
30
30
|
"/static/",
|
|
31
31
|
"/api/docs/",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_auth"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.44"
|
|
4
4
|
description = "Session-cookie authentication primitives — middleware, login/logout, redirect helpers for simple_module"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -25,9 +25,9 @@ dependencies = [
|
|
|
25
25
|
"PyJWT[crypto]>=2.8,<3",
|
|
26
26
|
"cryptography>=42",
|
|
27
27
|
"httpx>=0.27,<0.29",
|
|
28
|
-
"simple_module_core==0.0.
|
|
29
|
-
"simple_module_db==0.0.
|
|
30
|
-
"simple_module_hosting==0.0.
|
|
28
|
+
"simple_module_core==0.0.44",
|
|
29
|
+
"simple_module_db==0.0.44",
|
|
30
|
+
"simple_module_hosting==0.0.44",
|
|
31
31
|
]
|
|
32
32
|
|
|
33
33
|
[project.entry-points.simple_module]
|
|
@@ -27,7 +27,7 @@ async def renewal(request, tmp_path):
|
|
|
27
27
|
await conn.run_sync(Base.metadata.create_all)
|
|
28
28
|
await conn.run_sync(LeaseRow.metadata.create_all)
|
|
29
29
|
|
|
30
|
-
tokens = import_module(f"{request.param}.tokens")
|
|
30
|
+
tokens = import_module(f"{request.param}.identity.tokens")
|
|
31
31
|
keys = SessionKeys("user_ctx", f"{request.param}_refresh_token", "retry", "attempted")
|
|
32
32
|
app = SimpleNamespace(
|
|
33
33
|
state=SimpleNamespace(
|
|
@@ -32,7 +32,7 @@ def test_principal_resolver_type_accepts_async_callable():
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def test_auth_state_initializes_with_empty_resolvers():
|
|
35
|
-
from auth.state import AuthState
|
|
35
|
+
from auth.core.state import AuthState
|
|
36
36
|
|
|
37
37
|
state = AuthState()
|
|
38
38
|
assert state.principal_resolvers == []
|
|
@@ -40,7 +40,7 @@ def test_auth_state_initializes_with_empty_resolvers():
|
|
|
40
40
|
|
|
41
41
|
def test_auth_state_resolvers_is_mutable_list():
|
|
42
42
|
"""Modules register resolvers by appending; the list must be a list, not a tuple."""
|
|
43
|
-
from auth.state import AuthState
|
|
43
|
+
from auth.core.state import AuthState
|
|
44
44
|
|
|
45
45
|
state = AuthState()
|
|
46
46
|
|
|
@@ -53,8 +53,8 @@ def test_auth_state_resolvers_is_mutable_list():
|
|
|
53
53
|
|
|
54
54
|
def test_auth_module_register_settings_populates_app_state():
|
|
55
55
|
"""``AuthModule.register_settings(app)`` must put an AuthState on ``app.state.auth``."""
|
|
56
|
+
from auth.core.state import AuthState
|
|
56
57
|
from auth.module import AuthModule
|
|
57
|
-
from auth.state import AuthState
|
|
58
58
|
from fastapi import FastAPI
|
|
59
59
|
|
|
60
60
|
app = FastAPI()
|
|
@@ -110,7 +110,7 @@ def test_auth_module_registers_principal_serializer():
|
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
def test_auth_state_has_auth_provider_field():
|
|
113
|
-
from auth.state import AuthState
|
|
113
|
+
from auth.core.state import AuthState
|
|
114
114
|
|
|
115
115
|
state = AuthState()
|
|
116
116
|
assert state.auth_provider is None
|
|
@@ -118,7 +118,7 @@ def test_auth_state_has_auth_provider_field():
|
|
|
118
118
|
|
|
119
119
|
def test_auth_state_accepts_auth_provider():
|
|
120
120
|
from auth.contracts.provider import AuthProvider
|
|
121
|
-
from auth.state import AuthState
|
|
121
|
+
from auth.core.state import AuthState
|
|
122
122
|
|
|
123
123
|
class FakeProvider:
|
|
124
124
|
name = "fake"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Refresh-outcome credentials are redacted from audit diffs."""
|
|
2
|
+
|
|
3
|
+
from auth.models import RefreshOutcome
|
|
4
|
+
from simple_module_db.audit import collect_audit_records
|
|
5
|
+
from sqlalchemy.orm import Session
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_refresh_outcome_credentials_are_redacted():
|
|
9
|
+
with Session() as session:
|
|
10
|
+
session.add(
|
|
11
|
+
RefreshOutcome(
|
|
12
|
+
outcome_key="private", lock_key="private", expires_at=1, session={"token": "x"}
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
changes = {c["field"]: c["new"] for c in collect_audit_records(session)[0].changes}
|
|
16
|
+
assert changes["lock_key"] == changes["session"] == "[redacted]"
|
|
@@ -7,10 +7,10 @@ from unittest.mock import AsyncMock
|
|
|
7
7
|
import httpx
|
|
8
8
|
import pytest
|
|
9
9
|
from auth.contracts.schemas import UserContext
|
|
10
|
-
from keycloak.
|
|
11
|
-
from keycloak.
|
|
12
|
-
from oidc.
|
|
13
|
-
from oidc.
|
|
10
|
+
from keycloak.core.settings import KeycloakSettings
|
|
11
|
+
from keycloak.identity.provider import KeycloakAuthProvider
|
|
12
|
+
from oidc.core.settings import OidcSettings
|
|
13
|
+
from oidc.identity.provider import OidcAuthProvider
|
|
14
14
|
from simple_module_hosting.session import SessionMiddleware
|
|
15
15
|
from starlette.requests import Request
|
|
16
16
|
|
|
@@ -101,11 +101,11 @@ async def test_real_users_login_cookie_is_anonymous_after_provider_switch(
|
|
|
101
101
|
db_session,
|
|
102
102
|
):
|
|
103
103
|
from fastapi import FastAPI
|
|
104
|
-
from users.db_adapter import UserDatabaseWithRoles
|
|
105
|
-
from users.manager import UserManager
|
|
104
|
+
from users.accounts.db_adapter import UserDatabaseWithRoles
|
|
105
|
+
from users.accounts.manager import UserManager
|
|
106
|
+
from users.accounts.provider import UsersAuthProvider, clear_session_version_cache
|
|
107
|
+
from users.core.settings import UsersSettings
|
|
106
108
|
from users.models import OAuthAccount, Role, User
|
|
107
|
-
from users.provider import UsersAuthProvider, clear_session_version_cache
|
|
108
|
-
from users.settings import UsersSettings
|
|
109
109
|
|
|
110
110
|
role = Role(name="admin")
|
|
111
111
|
user = User(email="authority@example.com", is_verified=True, roles=[role])
|
|
@@ -9,8 +9,8 @@ import jwt
|
|
|
9
9
|
import pytest
|
|
10
10
|
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
11
11
|
from jwt.algorithms import RSAAlgorithm
|
|
12
|
-
from keycloak.jwks import JWKSCache as KeycloakJWKS
|
|
13
|
-
from oidc.jwks import JWKSCache as OidcJWKS
|
|
12
|
+
from keycloak.identity.jwks import JWKSCache as KeycloakJWKS
|
|
13
|
+
from oidc.identity.jwks import JWKSCache as OidcJWKS
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
@pytest.fixture(params=[KeycloakJWKS, OidcJWKS])
|
|
@@ -5,8 +5,8 @@ import time
|
|
|
5
5
|
import jwt
|
|
6
6
|
import pytest
|
|
7
7
|
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
8
|
-
from keycloak.jwks import JWKSCache as KeycloakJWKS
|
|
9
|
-
from oidc.jwks import JWKSCache as OidcJWKS
|
|
8
|
+
from keycloak.identity.jwks import JWKSCache as KeycloakJWKS
|
|
9
|
+
from oidc.identity.jwks import JWKSCache as OidcJWKS
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@pytest.fixture(params=[KeycloakJWKS, OidcJWKS])
|
|
@@ -12,7 +12,7 @@ from sqlalchemy import create_engine, inspect
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def test_refresh_outcome_sqlite_roundtrip():
|
|
15
|
-
root = Path(__file__).resolve().parents[
|
|
15
|
+
root = Path(__file__).resolve().parents[5]
|
|
16
16
|
script = ScriptDirectory.from_config(Config(str(root / "host/alembic.ini")))
|
|
17
17
|
migration = script.get_revision("auth@head").module
|
|
18
18
|
engine = create_engine("sqlite://")
|
|
@@ -7,8 +7,8 @@ import pytest
|
|
|
7
7
|
from cryptography.fernet import Fernet
|
|
8
8
|
from cryptography.hazmat.primitives import hashes
|
|
9
9
|
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
|
|
10
|
-
from keycloak import tokens as keycloak_tokens
|
|
11
|
-
from oidc import tokens as oidc_tokens
|
|
10
|
+
from keycloak.identity import tokens as keycloak_tokens
|
|
11
|
+
from oidc.identity import tokens as oidc_tokens
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
@pytest.fixture(params=[("keycloak", keycloak_tokens), ("oidc", oidc_tokens)])
|
|
@@ -9,7 +9,7 @@ from unittest.mock import MagicMock
|
|
|
9
9
|
|
|
10
10
|
import pytest
|
|
11
11
|
from auth.contracts.schemas import UserContext
|
|
12
|
-
from auth.deps import get_current_user, require_permission
|
|
12
|
+
from auth.web.deps import get_current_user, require_permission
|
|
13
13
|
from fastapi import HTTPException
|
|
14
14
|
from simple_module_core.i18n import I18nRegistry, Translator
|
|
15
15
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""The legacy any-of permission helper carries a migration warning (#698)."""
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
|
-
from auth.deps import require_permission
|
|
4
|
+
from auth.web.deps import require_permission
|
|
5
5
|
from simple_module_core.deprecation import registered_deprecations
|
|
6
6
|
|
|
7
7
|
|
|
@@ -9,5 +9,7 @@ def test_auth_require_permission_warns_and_registers_removal():
|
|
|
9
9
|
with pytest.warns(DeprecationWarning, match="RequiresPermission"):
|
|
10
10
|
dependency = require_permission("products.view")
|
|
11
11
|
assert callable(dependency.dependency)
|
|
12
|
-
entry = next(
|
|
12
|
+
entry = next(
|
|
13
|
+
d for d in registered_deprecations() if d.name == "auth.web.deps.require_permission"
|
|
14
|
+
)
|
|
13
15
|
assert entry.remove_in == "0.1.0"
|
|
@@ -5,8 +5,8 @@ from __future__ import annotations
|
|
|
5
5
|
import httpx
|
|
6
6
|
import pytest
|
|
7
7
|
from auth.contracts.schemas import UserContext
|
|
8
|
-
from auth.
|
|
9
|
-
from auth.
|
|
8
|
+
from auth.core.state import AuthState
|
|
9
|
+
from auth.web.middleware import AuthMiddleware
|
|
10
10
|
from fastapi import FastAPI, Request
|
|
11
11
|
from starlette.middleware.sessions import SessionMiddleware
|
|
12
12
|
from starlette.responses import JSONResponse
|
|
@@ -4,8 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import httpx
|
|
6
6
|
import pytest
|
|
7
|
-
from auth.
|
|
8
|
-
from auth.
|
|
7
|
+
from auth.core.state import AuthState
|
|
8
|
+
from auth.web.middleware import AuthMiddleware
|
|
9
9
|
from fastapi import FastAPI, Request
|
|
10
10
|
from simple_module_core.redirect_safety import SESSION_NEXT_KEY
|
|
11
11
|
from starlette.middleware.sessions import SessionMiddleware
|
|
@@ -10,8 +10,8 @@ from __future__ import annotations
|
|
|
10
10
|
import httpx
|
|
11
11
|
import pytest
|
|
12
12
|
from auth.contracts.schemas import UserContext
|
|
13
|
-
from auth.
|
|
14
|
-
from auth.
|
|
13
|
+
from auth.core.state import AuthState
|
|
14
|
+
from auth.web.middleware import AuthMiddleware
|
|
15
15
|
from fastapi import APIRouter, FastAPI
|
|
16
16
|
from simple_module_core.redirect_safety import SESSION_NEXT_KEY
|
|
17
17
|
from starlette.middleware.sessions import SessionMiddleware
|
|
@@ -152,7 +152,7 @@ async def test_signed_in_unknown_path_is_404():
|
|
|
152
152
|
|
|
153
153
|
|
|
154
154
|
async def test_probe_failure_fails_closed(monkeypatch):
|
|
155
|
-
import auth._route_match as rm
|
|
155
|
+
import auth.web._route_match as rm
|
|
156
156
|
|
|
157
157
|
def boom(router, probe):
|
|
158
158
|
raise RuntimeError("router exploded")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|