[#24] Use verify_api_key for /{region}/gtfs
All checks were successful
Amarillo/amarillo-gitea/amarillo-core/pipeline/head This commit looks good
All checks were successful
Amarillo/amarillo-gitea/amarillo-core/pipeline/head This commit looks good
This commit is contained in:
parent
18c015a3b6
commit
e638300ba5
|
|
@ -5,7 +5,7 @@ from typing import List
|
||||||
from fastapi import APIRouter, HTTPException, status, Depends
|
from fastapi import APIRouter, HTTPException, status, Depends
|
||||||
|
|
||||||
from amarillo.app.models.Carpool import Region
|
from amarillo.app.models.Carpool import Region
|
||||||
from amarillo.app.routers.agencyconf import verify_admin_api_key
|
from amarillo.app.routers.agencyconf import verify_admin_api_key, verify_api_key
|
||||||
from amarillo.app.services.regions import RegionService
|
from amarillo.app.services.regions import RegionService
|
||||||
from amarillo.app.utils.container import container
|
from amarillo.app.utils.container import container
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
|
|
@ -64,7 +64,7 @@ def _assert_region_exists(region_id: str) -> Region:
|
||||||
status.HTTP_404_NOT_FOUND: {"description": "Region not found"},
|
status.HTTP_404_NOT_FOUND: {"description": "Region not found"},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
async def get_file(region_id: str, user: str = Depends(verify_admin_api_key)):
|
async def get_file(region_id: str, user: str = Depends(verify_api_key)):
|
||||||
_assert_region_exists(region_id)
|
_assert_region_exists(region_id)
|
||||||
return FileResponse(f'data/gtfs/amarillo.{region_id}.gtfs.zip')
|
return FileResponse(f'data/gtfs/amarillo.{region_id}.gtfs.zip')
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ async def get_file(region_id: str, user: str = Depends(verify_admin_api_key)):
|
||||||
status.HTTP_400_BAD_REQUEST: {"description": "Bad request, e.g. because format is not supported, i.e. neither protobuf nor json."}
|
status.HTTP_400_BAD_REQUEST: {"description": "Bad request, e.g. because format is not supported, i.e. neither protobuf nor json."}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
async def get_file(region_id: str, format: str = 'protobuf', user: str = Depends(verify_admin_api_key)):
|
async def get_file(region_id: str, format: str = 'protobuf', user: str = Depends(verify_api_key)):
|
||||||
_assert_region_exists(region_id)
|
_assert_region_exists(region_id)
|
||||||
if format == 'json':
|
if format == 'json':
|
||||||
return FileResponse(f'data/gtfs/amarillo.{region_id}.gtfsrt.json')
|
return FileResponse(f'data/gtfs/amarillo.{region_id}.gtfsrt.json')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue