feat: first commit, auth
This commit is contained in:
0
schemas/__init__.py
Normal file
0
schemas/__init__.py
Normal file
7
schemas/dto.py
Normal file
7
schemas/dto.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class KeyPair:
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
11
schemas/jwt.py
Normal file
11
schemas/jwt.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from schemas.providers import ProvidersType
|
||||
|
||||
|
||||
class JWTPayload(BaseModel):
|
||||
sub: int = Field(description="User ID")
|
||||
iss: ProvidersType = Field(description="Issuer")
|
||||
exp: float = Field(default_factory=lambda: datetime.now(UTC).timestamp())
|
||||
27
schemas/login.py
Normal file
27
schemas/login.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
from schemas.providers import ProvidersType
|
||||
from schemas.user import UserInfo
|
||||
|
||||
|
||||
class TelegramData(BaseModel): ...
|
||||
|
||||
|
||||
class UserLoginData(BaseModel):
|
||||
provider: ProvidersType
|
||||
|
||||
username: str | None = None
|
||||
password: str | None = None
|
||||
|
||||
telegram: TelegramData | None = None
|
||||
|
||||
|
||||
class UserLogin(BaseModel):
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
user: UserInfo
|
||||
|
||||
|
||||
class UserTokens(BaseModel):
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
3
schemas/providers.py
Normal file
3
schemas/providers.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from typing import Literal
|
||||
|
||||
ProvidersType = Literal["credentials", "telegram", "api"]
|
||||
12
schemas/registration.py
Normal file
12
schemas/registration.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from schemas.providers import ProvidersType
|
||||
|
||||
|
||||
class UserRegistration(BaseModel):
|
||||
telegram_id: str | None = Field()
|
||||
|
||||
username: str | None = Field()
|
||||
password: str | None = Field()
|
||||
|
||||
provider: ProvidersType
|
||||
6
schemas/user.py
Normal file
6
schemas/user.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class UserInfo(BaseModel):
|
||||
username: str | None = Field()
|
||||
telegram_id: str | None = Field()
|
||||
Reference in New Issue
Block a user