bh-coders / trip-planer

Mobile, Web and Rest API
5 stars 0 forks source link

#117 backend swagger UI authorization #124

Closed MarcinNiemczyk closed 7 months ago

MarcinNiemczyk commented 8 months ago
  1. Add 'Authorize' button to Swagger UI by leveraging built-in FastAPI token interceptors so we can access locked endpoints that require Bearer token. https://fastapi.tiangolo.com/reference/security/#fastapi.security.HTTPBearer

  2. Refactored the verification of JWT Tokens: previously, we injected an unused variable into the controller function; now, we utilize dependencies in the router decorator.

Example usage:

@router.get("/all", dependencies=[Depends(verify_jwt)])
def get_all_attractions(db: Session = Depends(get_db)) -> list[AttractionSchema]:
    return _attraction_service.get_all_attractions(db)