mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 19:28:07 +00:00
Symbols endpoints (except upload) don't require authentication.
This commit is contained in:
parent
91a6384a59
commit
1f0ceb6f74
@ -95,7 +95,6 @@ router.include_router(
|
|||||||
|
|
||||||
router.include_router(
|
router.include_router(
|
||||||
symbols.router,
|
symbols.router,
|
||||||
dependencies=[Depends(get_current_active_user)],
|
|
||||||
prefix="/symbols", tags=["Symbols"]
|
prefix="/symbols", tags=["Symbols"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ API routes for symbols.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from fastapi import APIRouter, Request, status
|
from fastapi import APIRouter, Request, Depends, status
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
@ -29,6 +29,8 @@ from gns3server.controller import Controller
|
|||||||
from gns3server import schemas
|
from gns3server import schemas
|
||||||
from gns3server.controller.controller_error import ControllerError, ControllerNotFoundError
|
from gns3server.controller.controller_error import ControllerError, ControllerNotFoundError
|
||||||
|
|
||||||
|
from .dependencies.authentication import get_current_active_user
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -57,7 +59,7 @@ async def get_symbol(symbol_id: str) -> FileResponse:
|
|||||||
symbol = controller.symbols.get_path(symbol_id)
|
symbol = controller.symbols.get_path(symbol_id)
|
||||||
return FileResponse(symbol)
|
return FileResponse(symbol)
|
||||||
except (KeyError, OSError) as e:
|
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(
|
@router.get(
|
||||||
@ -75,10 +77,24 @@ async def get_symbol_dimensions(symbol_id: str) -> dict:
|
|||||||
symbol_dimensions = {"width": width, "height": height}
|
symbol_dimensions = {"width": width, "height": height}
|
||||||
return symbol_dimensions
|
return symbol_dimensions
|
||||||
except (KeyError, OSError, ValueError) as e:
|
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:
|
async def upload_symbol(symbol_id: str, request: Request) -> None:
|
||||||
"""
|
"""
|
||||||
Upload a symbol file.
|
Upload a symbol file.
|
||||||
@ -95,13 +111,3 @@ async def upload_symbol(symbol_id: str, request: Request) -> None:
|
|||||||
|
|
||||||
# Reset the symbol list
|
# Reset the symbol list
|
||||||
controller.symbols.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()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user