xn-auth 0.2.2.dev1__tar.gz → 0.2.2.dev2__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.
- {xn_auth-0.2.2.dev1/xn_auth.egg-info → xn_auth-0.2.2.dev2}/PKG-INFO +1 -1
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/x_auth/__init__.py +2 -2
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/x_auth/model.py +4 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/x_auth/router.py +2 -3
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2/xn_auth.egg-info}/PKG-INFO +1 -1
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/.env.dist +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/.gitignore +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/.pre-commit-config.yaml +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/README.md +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/makefile +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/pyproject.toml +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/setup.cfg +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/x_auth/backend.py +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/x_auth/depend.py +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/x_auth/enums.py +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/x_auth/pydantic.py +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/xn_auth.egg-info/SOURCES.txt +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/xn_auth.egg-info/dependency_links.txt +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/xn_auth.egg-info/requires.txt +0 -0
- {xn_auth-0.2.2.dev1 → xn_auth-0.2.2.dev2}/xn_auth.egg-info/top_level.txt +0 -0
|
@@ -54,8 +54,8 @@ class BearerModel(HTTPBase):
|
|
|
54
54
|
class BearerSecurity(SecurityBase):
|
|
55
55
|
"""HTTP Bearer token authentication"""
|
|
56
56
|
|
|
57
|
-
def __init__(self,
|
|
58
|
-
self.model =
|
|
57
|
+
def __init__(self, model_: BearerModel = BearerModel(), auto_error: bool = False, scheme_name: str = None):
|
|
58
|
+
self.model = model_
|
|
59
59
|
self.scheme_name = scheme_name or self.__class__.__name__
|
|
60
60
|
self.auto_error = auto_error
|
|
61
61
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from tortoise import fields
|
|
2
|
+
from x_auth.pydantic import AuthUser
|
|
2
3
|
from x_model.model import Model as BaseModel, TsTrait
|
|
3
4
|
|
|
4
5
|
from x_auth.enums import UserStatus, Role, Scope
|
|
@@ -29,5 +30,8 @@ class User(Model, TsTrait):
|
|
|
29
30
|
def _can(self, scope: Scope) -> bool:
|
|
30
31
|
return bool(self.role.value & scope)
|
|
31
32
|
|
|
33
|
+
def get_auth(self) -> AuthUser:
|
|
34
|
+
return AuthUser.model_validate(self, from_attributes=True)
|
|
35
|
+
|
|
32
36
|
class Meta:
|
|
33
37
|
table_description = "Users"
|
|
@@ -21,7 +21,7 @@ class AuthRouter:
|
|
|
21
21
|
async def refresh(auth_user: AuthUser = self.depend.AUTHENTICATED) -> Token:
|
|
22
22
|
try:
|
|
23
23
|
db_user: User = await self.db_user_model[auth_user.id]
|
|
24
|
-
auth_user =
|
|
24
|
+
auth_user: AuthUser = db_user.get_auth()
|
|
25
25
|
except ConfigurationError:
|
|
26
26
|
raise AuthException(AuthFailReason.username, f"Not inicialized user model: {User})", 500)
|
|
27
27
|
except Exception:
|
|
@@ -46,5 +46,4 @@ class AuthRouter:
|
|
|
46
46
|
db_user: User = await self.db_user_model.create(**data)
|
|
47
47
|
except IntegrityError as e:
|
|
48
48
|
raise HTTPException(FailReason.body, e)
|
|
49
|
-
|
|
50
|
-
return self._user2tok(user)
|
|
49
|
+
return self._user2tok(db_user.get_auth())
|
|
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
|