abs-auth-rbac-core 0.1.2__tar.gz → 0.1.3__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.
Potentially problematic release.
This version of abs-auth-rbac-core might be problematic. Click here for more details.
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/PKG-INFO +1 -1
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/auth/middleware.py +5 -4
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/pyproject.toml +1 -1
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/README.md +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/__init__.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/auth/__init__.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/auth/auth_functions.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/auth/jwt_functions.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/__init__.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/base_model.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/gov_casbin_rule.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/permissions.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/rbac_model.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/role_permission.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/roles.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/seeder/permission_seeder.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/user.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/user_role.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/rbac/__init__.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/rbac/decorator.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/rbac/policy.conf +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/rbac/service.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/util/__init__.py +0 -0
- {abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/util/permission_constants.py +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from fastapi import Depends
|
|
1
|
+
from fastapi import Depends, Request
|
|
2
2
|
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
|
3
3
|
import logging
|
|
4
4
|
from typing import Callable, Any
|
|
@@ -21,13 +21,12 @@ def auth_middleware(
|
|
|
21
21
|
This middleware is used for authentication of the user.
|
|
22
22
|
Args:
|
|
23
23
|
db_session: Callable[...,Any]: Session of the SQLAlchemy database engine
|
|
24
|
-
Users: User table fo teh system
|
|
25
24
|
jwt_secret_key: Secret key of the JWT for jwt functions
|
|
26
25
|
jwt_algorithm: Algorithm used for JWT
|
|
27
26
|
|
|
28
27
|
Returns:
|
|
29
28
|
"""
|
|
30
|
-
def get_auth(token: HTTPAuthorizationCredentials = Depends(security)):
|
|
29
|
+
async def get_auth(request: Request, token: HTTPAuthorizationCredentials = Depends(security)):
|
|
31
30
|
jwt_functions = JWTFunctions(secret_key=jwt_secret_key,algorithm=jwt_algorithm)
|
|
32
31
|
try:
|
|
33
32
|
if not token or not token.credentials:
|
|
@@ -42,7 +41,9 @@ def auth_middleware(
|
|
|
42
41
|
logger.error(f"Authentication failed: User with id {uuid} not found")
|
|
43
42
|
raise UnauthorizedError(detail="Authentication failed")
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
# Attach user to request state
|
|
45
|
+
request.state.user = user
|
|
46
|
+
return user # Still return user for backward compatibility
|
|
46
47
|
|
|
47
48
|
except Exception as e:
|
|
48
49
|
logger.error(f"Authentication error: {str(e)}", exc_info=True)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/auth/auth_functions.py
RENAMED
|
File without changes
|
{abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/auth/jwt_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
{abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/base_model.py
RENAMED
|
File without changes
|
{abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/gov_casbin_rule.py
RENAMED
|
File without changes
|
{abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/permissions.py
RENAMED
|
File without changes
|
{abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/rbac_model.py
RENAMED
|
File without changes
|
{abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/role_permission.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abs_auth_rbac_core-0.1.2 → abs_auth_rbac_core-0.1.3}/abs_auth_rbac_core/models/user_role.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|