diff --git a/gns3server/api/routes/controller/__init__.py b/gns3server/api/routes/controller/__init__.py index 2e12010e..71e0cc02 100644 --- a/gns3server/api/routes/controller/__init__.py +++ b/gns3server/api/routes/controller/__init__.py @@ -95,7 +95,6 @@ router.include_router( router.include_router( symbols.router, - dependencies=[Depends(get_current_active_user)], prefix="/symbols", tags=["Symbols"] ) diff --git a/gns3server/api/routes/controller/symbols.py b/gns3server/api/routes/controller/symbols.py index 127f2c14..334ae926 100644 --- a/gns3server/api/routes/controller/symbols.py +++ b/gns3server/api/routes/controller/symbols.py @@ -21,7 +21,7 @@ API routes for symbols. import os -from fastapi import APIRouter, Request, status +from fastapi import APIRouter, Request, Depends, status from fastapi.responses import FileResponse from typing import List @@ -29,6 +29,8 @@ from gns3server.controller import Controller from gns3server import schemas from gns3server.controller.controller_error import ControllerError, ControllerNotFoundError +from .dependencies.authentication import get_current_active_user + import logging log = logging.getLogger(__name__) @@ -57,7 +59,7 @@ async def get_symbol(symbol_id: str) -> FileResponse: symbol = controller.symbols.get_path(symbol_id) return FileResponse(symbol) except (KeyError, OSError) as e: - return ControllerNotFoundError(f"Could not get symbol file: {e}") + raise ControllerNotFoundError(f"Could not get symbol file: {e}") @router.get( @@ -75,10 +77,24 @@ async def get_symbol_dimensions(symbol_id: str) -> dict: symbol_dimensions = {"width": width, "height": height} return symbol_dimensions except (KeyError, OSError, ValueError) as e: - return ControllerNotFoundError(f"Could not get symbol file: {e}") + raise ControllerNotFoundError(f"Could not get symbol file: {e}") -@router.post("/{symbol_id:path}/raw", status_code=status.HTTP_204_NO_CONTENT) +@router.get("/default_symbols") +def get_default_symbols() -> dict: + """ + Return all default symbols. + """ + + controller = Controller.instance() + return controller.symbols.default_symbols() + + +@router.post( + "/{symbol_id:path}/raw", + dependencies=[Depends(get_current_active_user)], + status_code=status.HTTP_204_NO_CONTENT +) async def upload_symbol(symbol_id: str, request: Request) -> None: """ Upload a symbol file. @@ -95,13 +111,3 @@ async def upload_symbol(symbol_id: str, request: Request) -> None: # Reset the symbol list controller.symbols.list() - - -@router.get("/default_symbols") -def get_default_symbols() -> dict: - """ - Return all default symbols. - """ - - controller = Controller.instance() - return controller.symbols.default_symbols()