feat(auth): implement authentication endpoints and JWT handling

This commit is contained in:
gabdevele
2026-04-12 20:18:33 +02:00 Unverified
parent f3979c56ef
commit cc8ae34838
18 changed files with 640 additions and 33 deletions
+19 -7
View File
@@ -1,17 +1,20 @@
from fastapi import APIRouter, HTTPException, status
from core.security import require_authenticated_user
from db.proxy import (
create_proxy,
delete_proxy,
get_proxy_by_port,
list_proxies as list_proxy_documents,
update_proxy,
)
from db.proxy import (
list_proxies as list_proxy_documents,
)
from fastapi import APIRouter, Depends, HTTPException, status
from models.proxy import ProxyCreateInput, ProxyUpdateInput
router = APIRouter(
prefix="/proxy",
tags=["Proxy"]
tags=["Proxy"],
dependencies=[Depends(require_authenticated_user)],
)
@@ -24,7 +27,10 @@ async def list_proxies_handler():
async def get_proxy(proxy_port: int):
proxy = await get_proxy_by_port(proxy_port)
if proxy is None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Proxy not found")
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Proxy not found",
)
return proxy
@@ -49,7 +55,10 @@ async def create_proxy_handler(payload: ProxyCreateInput):
async def edit_proxy(proxy_port: int, payload: ProxyUpdateInput):
updated_proxy = await update_proxy(proxy_port, payload)
if updated_proxy is None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Proxy not found")
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Proxy not found",
)
return updated_proxy
@@ -57,4 +66,7 @@ async def edit_proxy(proxy_port: int, payload: ProxyUpdateInput):
async def remove_proxy(proxy_port: int):
deleted = await delete_proxy(proxy_port)
if not deleted:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Proxy not found")
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Proxy not found",
)