|
4 | 4 |
|
5 | 5 | import aiofiles |
6 | 6 | import aiofiles.os |
| 7 | +from auth_lib.fastapi import UnionAuth |
7 | 8 | from fastapi import APIRouter, File, UploadFile |
8 | 9 | from fastapi.exceptions import HTTPException |
9 | 10 | from fastapi.params import Depends |
@@ -159,7 +160,10 @@ async def send(inp: SendInput, settings: Settings = Depends(get_settings)): |
159 | 160 | response_model=SendOutput, |
160 | 161 | ) |
161 | 162 | async def upload_file( |
162 | | - pin: str, file: UploadFile = File(...), settings: Settings = Depends(get_settings) |
| 163 | + pin: str, |
| 164 | + file: UploadFile = File(...), |
| 165 | + settings: Settings = Depends(get_settings), |
| 166 | + _=Depends(UnionAuth(scopes=["print.file.create"], allow_none=False, auto_error=True)), |
163 | 167 | ): |
164 | 168 | """Загрузить файл на сервер. |
165 | 169 |
|
@@ -229,7 +233,10 @@ async def upload_file( |
229 | 233 | response_model=SendOutput, |
230 | 234 | ) |
231 | 235 | async def update_file_options( |
232 | | - pin: str, inp: SendInputUpdate, settings: Settings = Depends(get_settings) |
| 236 | + pin: str, |
| 237 | + inp: SendInputUpdate, |
| 238 | + settings: Settings = Depends(get_settings), |
| 239 | + _=Depends(UnionAuth(scopes=["print.file.update"], allow_none=False, auto_error=True)), |
233 | 240 | ): |
234 | 241 | """Обновляет настройки печати. |
235 | 242 |
|
@@ -275,7 +282,11 @@ async def update_file_options( |
275 | 282 | }, |
276 | 283 | response_model=ReceiveOutput, |
277 | 284 | ) |
278 | | -async def print_file(pin: str, settings: Settings = Depends(get_settings)): |
| 285 | +async def print_file( |
| 286 | + pin: str, |
| 287 | + settings: Settings = Depends(get_settings), |
| 288 | + _=Depends(UnionAuth(scopes=["print.file.get"], allow_none=False, auto_error=True)), |
| 289 | +): |
279 | 290 | """Получить файл для печати. |
280 | 291 |
|
281 | 292 | Требует пин-код, полученный в методе POST `/file`. Файл можно скачать |
|
0 commit comments