Remnawave_python-sdk/remnawave/controllers/auth.py
Artem 9e2822774a
feat: Enhance subscription and external squad management
- Updated NodeUsageDto to include node_uuid and changed date to datetime.
- Changed total fields in subscription and subscription request history models from float to int.
- Introduced response rules and conditions for subscription settings, including new models for response modifications.
- Added external squads management with CRUD operations and associated models.
- Implemented passkey management with registration and verification endpoints.
- Enhanced snippets management with full CRUD operations and validation.
- Added OAuth2 provider enum for better authentication handling.
2025-10-28 00:44:15 +01:00

85 lines
No EOL
2.7 KiB
Python

from typing import Annotated
from rapid_api_client.annotations import PydanticBody
from remnawave.models import (
GetStatusResponseDto,
LoginRequestDto,
LoginResponseDto,
OAuth2AuthorizeRequestDto,
OAuth2AuthorizeResponseDto,
OAuth2CallbackRequestDto,
OAuth2CallbackResponseDto,
VerifyPasskeyAuthenticationRequestDto,
VerifyPasskeyAuthenticationResponseDto,
GetPasskeyAuthenticationOptionsResponseDto,
RegisterRequestDto,
RegisterResponseDto,
TelegramCallbackRequestDto,
TelegramCallbackResponseDto,
)
from remnawave.rapid import BaseController, get, post
class AuthController(BaseController):
@post("/auth/login", response_class=LoginResponseDto)
async def login(
self,
body: Annotated[LoginRequestDto, PydanticBody()],
) -> LoginResponseDto:
"""Login"""
...
@post("/auth/register", response_class=RegisterResponseDto)
async def register(
self,
body: Annotated[RegisterRequestDto, PydanticBody()],
) -> RegisterResponseDto:
"""Register"""
...
@get("/auth/status", response_class=GetStatusResponseDto)
async def get_status(
self,
) -> GetStatusResponseDto:
"""Get status"""
...
@post("/auth/oauth2/tg/callback", response_class=TelegramCallbackResponseDto)
async def oauth2_tg_callback(
self,
body: Annotated[TelegramCallbackRequestDto, PydanticBody()],
) -> TelegramCallbackResponseDto:
"""OAuth2 Telegram callback"""
...
@post("/auth/oauth2/authorize", response_class=OAuth2AuthorizeResponseDto)
async def oauth2_authorize(
self,
body: Annotated[OAuth2AuthorizeRequestDto, PydanticBody()],
) -> OAuth2AuthorizeResponseDto:
"""Initiate OAuth2 authorization"""
...
@post("/auth/oauth2/callback", response_class=OAuth2CallbackResponseDto)
async def oauth2_callback(
self,
body: Annotated[OAuth2CallbackRequestDto, PydanticBody()],
) -> OAuth2CallbackResponseDto:
"""Callback from OAuth2"""
...
@get("/auth/passkey/authentication/options", response_class=GetPasskeyAuthenticationOptionsResponseDto)
async def passkey_authentication_options(
self,
) -> GetPasskeyAuthenticationOptionsResponseDto:
"""Get the authentication options for passkey"""
...
@post("/auth/passkey/authentication/verify", response_class=VerifyPasskeyAuthenticationResponseDto)
async def passkey_authentication_verify(
self,
body: Annotated[VerifyPasskeyAuthenticationRequestDto, PydanticBody()],
) -> VerifyPasskeyAuthenticationResponseDto:
"""Verify the authentication for passkey"""
...