add discord auth skeleton
This commit is contained in:
parent
59ad391a2b
commit
c6eaf49779
3 changed files with 59 additions and 1 deletions
|
@ -6,7 +6,7 @@ from . import blueprints
|
|||
from .db.aio import async_session
|
||||
from .db.util import validate_token
|
||||
from .exceptions import ErrorCode, ExpectedError
|
||||
from .settings import SECRET_KEY, BASE_DOMAIN
|
||||
from .settings import BASE_DOMAIN, SECRET_KEY
|
||||
|
||||
app = Quart(__name__, host_matching=True, static_host=BASE_DOMAIN)
|
||||
app.secret_key = SECRET_KEY
|
||||
|
|
43
foxnouns/blueprints/v2/auth/__init__.py
Normal file
43
foxnouns/blueprints/v2/auth/__init__.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from foxnouns.models.user import SelfUserModel
|
||||
|
||||
|
||||
class OAuthCallbackRequest(BaseModel):
|
||||
callback_domain: str
|
||||
code: str
|
||||
state: str
|
||||
|
||||
|
||||
class BaseCallbackResponse(BaseModel):
|
||||
"""The base class for callback responses."""
|
||||
|
||||
has_account: bool
|
||||
|
||||
|
||||
class ExistingUserCallbackResponse(BaseCallbackResponse):
|
||||
"""The class returned when a user already exists."""
|
||||
|
||||
token: str
|
||||
user: SelfUserModel
|
||||
|
||||
|
||||
class NewUserCallbackResponse(BaseCallbackResponse):
|
||||
"""The class returned when the user is new and has to create an account."""
|
||||
|
||||
remote_username: str
|
||||
ticket: str
|
||||
require_captcha: bool
|
||||
|
||||
|
||||
class DeletedUserCallbackResponse(BaseCallbackResponse):
|
||||
"""The class returned when the user has been deleted."""
|
||||
|
||||
token: str
|
||||
user: SelfUserModel
|
||||
|
||||
deleted_at: datetime
|
||||
self_delete: bool
|
||||
delete_reason: str | None = Field(default=None)
|
15
foxnouns/blueprints/v2/auth/discord.py
Normal file
15
foxnouns/blueprints/v2/auth/discord.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from quart import Blueprint
|
||||
from quart_schema import validate_request, validate_response
|
||||
|
||||
from foxnouns.settings import BASE_DOMAIN
|
||||
|
||||
from . import BaseCallbackResponse, OAuthCallbackRequest
|
||||
|
||||
bp = Blueprint("discord", __name__)
|
||||
|
||||
|
||||
@bp.post("/api/v2/auth/discord/callback", host=BASE_DOMAIN)
|
||||
@validate_request(OAuthCallbackRequest)
|
||||
@validate_response(BaseCallbackResponse)
|
||||
async def discord_callback(data: OAuthCallbackRequest):
|
||||
raise NotImplementedError()
|
Loading…
Reference in a new issue