feat: service token introduction
This commit is contained in:
@@ -14,5 +14,5 @@ class KeyPair:
|
||||
@dataclass
|
||||
class AuthContext:
|
||||
user: User
|
||||
auth_method: Literal["jwt"]
|
||||
auth_method: Literal["jwt", "service"]
|
||||
service: str | None = None
|
||||
|
||||
@@ -4,3 +4,8 @@ from enum import StrEnum
|
||||
class SubscriptionStatus(StrEnum):
|
||||
ACTIVE = "active"
|
||||
EXPIRED = "expired"
|
||||
|
||||
|
||||
class ServiceSignatureStatus(StrEnum):
|
||||
ACTIVE = "active"
|
||||
INACTIVE = "inactive"
|
||||
|
||||
@@ -3,8 +3,17 @@ from pydantic import BaseModel, Field
|
||||
from core.exp import get_exp
|
||||
from schemas.providers import ProvidersType
|
||||
|
||||
type NumericDate = int | float
|
||||
|
||||
class JWTPayload(BaseModel):
|
||||
|
||||
class UserJWTPayload(BaseModel):
|
||||
sub: str = Field(description="User ID")
|
||||
iss: ProvidersType = Field(description="Issuer")
|
||||
exp: float = Field(default_factory=get_exp)
|
||||
exp: NumericDate = Field(default_factory=get_exp)
|
||||
|
||||
|
||||
class ServiceJWTPayload(BaseModel):
|
||||
iss: str = Field(description="Service name")
|
||||
iat: NumericDate = Field(description="Issued at")
|
||||
exp: NumericDate = Field(description="Expiration date")
|
||||
acting_as: str = Field(description="Subject of issued call, formatted as `service:id`")
|
||||
|
||||
@@ -14,6 +14,6 @@ class SubscriptionData(BaseModel):
|
||||
|
||||
class UserInfo(BaseModel):
|
||||
username: str | None = Field(None)
|
||||
telegram_id: str | None = Field(None)
|
||||
telegram_id: int | None = Field(None)
|
||||
referal_code: str = Field()
|
||||
bonus_balance: float = Field()
|
||||
|
||||
Reference in New Issue
Block a user