(20241127) Testing GMail auth.
This commit is contained in:
+37
-12
@@ -51,7 +51,8 @@ from utils_v2.string import regex
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
# --- Nothing Yet
|
||||
# RegEx Patterns:
|
||||
REGEX_SESSION_TOKEN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
@@ -71,20 +72,35 @@ from utils_v2.string import regex
|
||||
# *****************************************************************************************************************
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
class OAuthMailAuthorizationRequestHeaders(BaseModel):
|
||||
|
||||
username: str = Field(description = "the username of the user")
|
||||
|
||||
password: str = Field(description = "the password of the user")
|
||||
|
||||
mode: Optional[str] = Field(
|
||||
description = "the mode through which this request came in",
|
||||
default = "N/A"
|
||||
sessionToken: str = Field(
|
||||
description = "the session token of the user who is requesting the service",
|
||||
pattern = REGEX_SESSION_TOKEN,
|
||||
frozen = True,
|
||||
alias = "X-Session-Token"
|
||||
)
|
||||
|
||||
remoteIp: Optional[str] = Field(
|
||||
description = "the ip addr of the client",
|
||||
default = "N/A"
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
# ┛
|
||||
|
||||
class Config:
|
||||
extra = "allow"
|
||||
|
||||
def model_dump(self, *args, **kwargs):
|
||||
return super().model_dump(*args, by_alias = True, **kwargs)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class OAuthMailAuthorizationRequestData(BaseModel):
|
||||
|
||||
mailClient: Literal["gmail"] = Field(
|
||||
description = "the e-mail provider like 'gmail'",
|
||||
frozen = True
|
||||
)
|
||||
|
||||
# ┏┓ ┏•
|
||||
@@ -95,6 +111,15 @@ class LoginRequest(BaseModel):
|
||||
class Config:
|
||||
extra = "forbid"
|
||||
|
||||
# ┓┏ ┓• ┓ •
|
||||
# ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓
|
||||
# ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗
|
||||
|
||||
@field_validator("mailClient", mode = "before")
|
||||
def to_lowercase(cls, value):
|
||||
if isinstance(value, str): value = value.strip().lower()
|
||||
return value
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
|
||||
Reference in New Issue
Block a user