first commit
This commit is contained in:
commit
d416fe4cce
69 changed files with 8269 additions and 0 deletions
49
backend/app/schemas/auth.py
Normal file
49
backend/app/schemas/auth.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
from enum import Enum
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
|
||||
class IdentifierType(str, Enum):
|
||||
email = "email"
|
||||
username = "username"
|
||||
mobile = "mobile"
|
||||
|
||||
|
||||
class AuthIdentifierBase(BaseModel):
|
||||
identifierType: IdentifierType
|
||||
identifier: str = Field(min_length=1, max_length=255)
|
||||
|
||||
@field_validator("identifier")
|
||||
@classmethod
|
||||
def strip_identifier(cls, value: str) -> str:
|
||||
normalized = value.strip()
|
||||
if not normalized:
|
||||
raise ValueError("identifier cannot be empty")
|
||||
return normalized
|
||||
|
||||
|
||||
class AuthSignupRequest(AuthIdentifierBase):
|
||||
saltAuth: str = Field(min_length=8)
|
||||
saltEnc: str = Field(min_length=8)
|
||||
authKeyMaterial: str = Field(min_length=8)
|
||||
|
||||
|
||||
class AuthLoginBootstrapRequest(AuthIdentifierBase):
|
||||
pass
|
||||
|
||||
|
||||
class AuthLoginRequest(AuthIdentifierBase):
|
||||
authKeyMaterial: str = Field(min_length=8)
|
||||
|
||||
|
||||
class AuthBootstrapResponse(BaseModel):
|
||||
identifierType: IdentifierType
|
||||
identifier: str
|
||||
saltAuth: str
|
||||
saltEnc: str
|
||||
|
||||
|
||||
class AuthTokenResponse(BaseModel):
|
||||
accessToken: str
|
||||
tokenType: str = "bearer"
|
||||
ownerId: str
|
||||
Loading…
Add table
Add a link
Reference in a new issue