fastapi-cachex 0.2.4__tar.gz → 0.2.5__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.
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/PKG-INFO +1 -1
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/session/dependencies.py +24 -2
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/pyproject.toml +1 -1
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/README.md +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/__init__.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/backends/__init__.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/backends/base.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/backends/config.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/backends/memcached.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/backends/memory.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/backends/redis.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/cache.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/dependencies.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/directives.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/exceptions.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/proxy.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/py.typed +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/routes.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/session/__init__.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/session/config.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/session/exceptions.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/session/manager.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/session/middleware.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/session/models.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/session/security.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/session/token_serializers.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/state/__init__.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/state/exceptions.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/state/manager.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/state/models.py +0 -0
- {fastapi_cachex-0.2.4 → fastapi_cachex-0.2.5}/fastapi_cachex/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastapi-cachex
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: A caching library for FastAPI with support for Cache-Control, ETag, and multiple backends.
|
|
5
5
|
Keywords: fastapi,cache,etag,cache-control,redis,memcached,in-memory
|
|
6
6
|
Author: allen0099
|
|
@@ -7,6 +7,8 @@ from fastapi import Depends
|
|
|
7
7
|
from fastapi import HTTPException
|
|
8
8
|
from fastapi import Request
|
|
9
9
|
from fastapi import status
|
|
10
|
+
from fastapi.security import HTTPAuthorizationCredentials
|
|
11
|
+
from fastapi.security import HTTPBearer
|
|
10
12
|
|
|
11
13
|
from .models import Session
|
|
12
14
|
|
|
@@ -14,11 +16,23 @@ if TYPE_CHECKING:
|
|
|
14
16
|
from .manager import SessionManager
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
# HTTPBearer security scheme for OpenAPI UI
|
|
20
|
+
_http_bearer = HTTPBearer(auto_error=False)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def get_optional_session(
|
|
24
|
+
request: Request,
|
|
25
|
+
credentials: HTTPAuthorizationCredentials | None = Depends(_http_bearer), # noqa: ARG001
|
|
26
|
+
) -> Session | None:
|
|
18
27
|
"""Get session from request state (optional).
|
|
19
28
|
|
|
29
|
+
This dependency automatically displays the authorization input box in OpenAPI/Swagger UI.
|
|
30
|
+
The actual authentication is handled by SessionMiddleware; the credentials parameter
|
|
31
|
+
is only used to generate the OpenAPI security scheme.
|
|
32
|
+
|
|
20
33
|
Args:
|
|
21
34
|
request: FastAPI request object
|
|
35
|
+
credentials: HTTPBearer credentials (for OpenAPI UI display only)
|
|
22
36
|
|
|
23
37
|
Returns:
|
|
24
38
|
Session object or None if not authenticated
|
|
@@ -26,11 +40,19 @@ def get_optional_session(request: Request) -> Session | None:
|
|
|
26
40
|
return getattr(request.state, "__fastapi_cachex_session", None)
|
|
27
41
|
|
|
28
42
|
|
|
29
|
-
def get_session(
|
|
43
|
+
def get_session(
|
|
44
|
+
request: Request,
|
|
45
|
+
credentials: HTTPAuthorizationCredentials | None = Depends(_http_bearer), # noqa: ARG001
|
|
46
|
+
) -> Session:
|
|
30
47
|
"""Get session from request state (required).
|
|
31
48
|
|
|
49
|
+
This dependency automatically displays the authorization input box in OpenAPI/Swagger UI.
|
|
50
|
+
The actual authentication is handled by SessionMiddleware; the credentials parameter
|
|
51
|
+
is only used to generate the OpenAPI security scheme.
|
|
52
|
+
|
|
32
53
|
Args:
|
|
33
54
|
request: FastAPI request object
|
|
55
|
+
credentials: HTTPBearer credentials (for OpenAPI UI display only)
|
|
34
56
|
|
|
35
57
|
Returns:
|
|
36
58
|
Session object
|
|
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
|