feat(auth): implement authentication endpoints and JWT handling
This commit is contained in:
+10
-5
@@ -1,12 +1,11 @@
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, Mapping
|
||||
|
||||
from motor.motor_asyncio import AsyncIOMotorCollection
|
||||
from pymongo import ReturnDocument
|
||||
|
||||
from core.mongodb import get_database
|
||||
from models.proxy import ProxyDocument, ProxyUpdateInput
|
||||
from models.service import ServiceEndpointDocument
|
||||
from motor.motor_asyncio import AsyncIOMotorCollection
|
||||
from pymongo import ReturnDocument
|
||||
from utils.proxy.types import ServiceConfig
|
||||
|
||||
COLLECTION_NAME = "proxies"
|
||||
@@ -45,7 +44,10 @@ async def create_proxy(
|
||||
proxy_port=proxy_port,
|
||||
name=name,
|
||||
code=code,
|
||||
service=ServiceEndpointDocument(address=service["address"], port=service["port"]),
|
||||
service=ServiceEndpointDocument(
|
||||
address=service["address"],
|
||||
port=service["port"],
|
||||
),
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
)
|
||||
@@ -73,7 +75,10 @@ async def list_proxies() -> list[ProxyDocument]:
|
||||
return proxies
|
||||
|
||||
|
||||
async def update_proxy(proxy_port: int, updates: ProxyUpdateInput) -> ProxyDocument | None:
|
||||
async def update_proxy(
|
||||
proxy_port: int,
|
||||
updates: ProxyUpdateInput,
|
||||
) -> ProxyDocument | None:
|
||||
payload = updates.model_dump(exclude_none=True)
|
||||
if not payload:
|
||||
return await get_proxy_by_port(proxy_port)
|
||||
|
||||
Reference in New Issue
Block a user