From 909ca5a21f1eea5575fdf916932734468c7833a5 Mon Sep 17 00:00:00 2001 From: gitfresnel <151745312+gitfresnel@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:16:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D1=89=D0=B8=D1=82=D0=B0=20=D1=80?= =?UTF-8?q?=D1=83=D1=87=D0=BA=D0=B8=20GET=20/file/{pin}=20(#86)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Изменения добавил авторизацию ручки GET /file/{pin} --- print_service/routes/file.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/print_service/routes/file.py b/print_service/routes/file.py index 5205e0f..1153efd 100644 --- a/print_service/routes/file.py +++ b/print_service/routes/file.py @@ -4,6 +4,7 @@ import aiofiles import aiofiles.os +from auth_lib.fastapi import UnionAuth from fastapi import APIRouter, File, UploadFile from fastapi.exceptions import HTTPException from fastapi.params import Depends @@ -159,7 +160,10 @@ async def send(inp: SendInput, settings: Settings = Depends(get_settings)): response_model=SendOutput, ) async def upload_file( - pin: str, file: UploadFile = File(...), settings: Settings = Depends(get_settings) + pin: str, + file: UploadFile = File(...), + settings: Settings = Depends(get_settings), + _=Depends(UnionAuth(scopes=["print.file.create"], allow_none=False, auto_error=True)), ): """Загрузить файл на сервер. @@ -229,7 +233,10 @@ async def upload_file( response_model=SendOutput, ) async def update_file_options( - pin: str, inp: SendInputUpdate, settings: Settings = Depends(get_settings) + pin: str, + inp: SendInputUpdate, + settings: Settings = Depends(get_settings), + _=Depends(UnionAuth(scopes=["print.file.update"], allow_none=False, auto_error=True)), ): """Обновляет настройки печати. @@ -275,7 +282,11 @@ async def update_file_options( }, response_model=ReceiveOutput, ) -async def print_file(pin: str, settings: Settings = Depends(get_settings)): +async def print_file( + pin: str, + settings: Settings = Depends(get_settings), + _=Depends(UnionAuth(scopes=["print.file.get"], allow_none=False, auto_error=True)), +): """Получить файл для печати. Требует пин-код, полученный в методе POST `/file`. Файл можно скачать