access tokens 0.1.1

This commit is contained in:
2026-07-23 13:06:44 +03:00
parent 4d61d873b5
commit 7199387e6f
6 changed files with 352 additions and 27 deletions

View File

@@ -7,6 +7,26 @@ from uuid import UUID
class Base(BaseModel):
model_config = {"from_attributes": True}
class PermissionsCreate(Base):
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
class PermissionsOut(Base):
id:Annotated[int, Field(..., description="id of the permission")]
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
class PermissionsGroupsCreate(Base):
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
class PermissionsGroupsOut(Base):
id:Annotated[int, Field(..., description="id of the permission group")]
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
class UserCreate(Base):
first_name:Annotated[str, Field(..., max_length=64,description="first name of the user")]
@@ -15,8 +35,9 @@ class UserCreate(Base):
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
plain_password:Annotated[str, Field(...,min_length=8,max_length=72, description="plain password of the user")]
status:Annotated[bool, Field(..., description="status of the user")]
permissions:Annotated[list[str], Field(..., description="permissions of the user")]
permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
direct_permissions:Annotated[list[str], Field(..., description="permissions of the user")]
group:Annotated[list[str], Field(..., description="permissions groups of the user")]
class UserOut(Base):
@@ -25,9 +46,10 @@ class UserOut(Base):
middle_name:Annotated[str, Field(..., max_length=64, description="middle name of the user")]
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
# permissions:Annotated[list[str], Field(..., description="permissions of the user")]
# permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
direct_permissions:Annotated[list[PermissionsOut], Field(..., description="permissions of the user")]
group:Annotated[list[PermissionsGroupsOut], Field(..., description="permissions groups of the user")]
class UserOutDB(UserOut):
id:Annotated[UUID, Field(..., description="Id of the user")]
status:Annotated[bool, Field(..., description="status of the user")]
@@ -40,25 +62,8 @@ class UserUpdate(Base):
middle_name:Annotated[str|None, Field(None, max_length=64,description="middle name of the user")]
email:Annotated[EmailStr|None, Field(None, min_length=5, max_length=255, description="email of the user")]
status:Annotated[bool|None, Field(None, description="status of the user")]
permissions:Annotated[list[str]|None, Field(None, description="permissions of the user")]
permission_groups:Annotated[list[str]|None, Field(None, description="permissions groups of the user")]
class PermissionsCreate(Base):
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
class PermissionsOut(Base):
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
class PermissionsGroupsCreate(Base):
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
class PermissionsGroupsOut(Base):
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
direct_permissions:Annotated[list[str]|None, Field(None, description="permissions of the user")]
group:Annotated[list[str]|None, Field(None, description="permissions groups of the user")]
class RefreshTokensCreate(Base):