Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#117 backend swagger UI authorization #124

Merged
merged 2 commits into from
Apr 15, 2024

Conversation

MarcinNiemczyk
Copy link
Collaborator

@MarcinNiemczyk MarcinNiemczyk commented Mar 25, 2024

  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)

@MarcinNiemczyk MarcinNiemczyk added the Backend Backend Ticket label Mar 25, 2024
@MarcinNiemczyk MarcinNiemczyk self-assigned this Mar 25, 2024
@MarcinNiemczyk MarcinNiemczyk requested a review from kwiats April 14, 2024 16:45
@MarcinNiemczyk MarcinNiemczyk merged commit 1c733a5 into dev Apr 15, 2024
1 check passed
@MarcinNiemczyk MarcinNiemczyk deleted the 117-backend-swagger-ui-authorization branch April 15, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Backend Ticket
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants