From b8ba5999731861f3c9132dc97ae77d97d5caf2d7 Mon Sep 17 00:00:00 2001 From: gitfresnel <151745312+gitfresnel@users.noreply.github.com> Date: Mon, 2 Sep 2024 08:53:00 +0300 Subject: [PATCH 1/2] f --- print_service/routes/file.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/print_service/routes/file.py b/print_service/routes/file.py index 5205e0f..1412e66 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 @@ -275,7 +276,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`. Файл можно скачать From c1023387496227ba60d55422416b0e648217925c Mon Sep 17 00:00:00 2001 From: gitfresnel <151745312+gitfresnel@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:50:45 +0300 Subject: [PATCH 2/2] f --- print_service/routes/file.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/print_service/routes/file.py b/print_service/routes/file.py index 1412e66..1153efd 100644 --- a/print_service/routes/file.py +++ b/print_service/routes/file.py @@ -160,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)), ): """Загрузить файл на сервер. @@ -230,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)), ): """Обновляет настройки печати.