one-zero-eight / music-room

API for music room booking
MIT License
0 stars 1 forks source link

Ensure security and make music room API public #33

Open dantetemplar opened 7 months ago

dantetemplar commented 7 months ago

Current situation

Music room API available only in docker compose network named music-room and all API clients should be inside this network.

Implementation

Related

docker-compose.yaml:44

networks:
  # Create a 'music-room' network for connecting Bot and other services
  music-room:
    driver: bridge
    name: music-room

dependencies.py:48

from src.schemas.auth import VerificationResult, VerificationSource  # noqa: E402

class SucceedVerificationResult(VerificationResult):
    success: bool = True
    user_id: int  # not optional
    source: VerificationSource

VerifiedDep: TypeAlias = Annotated[SucceedVerificationResult, Depends(verify_request)]

Example of endpoint with verification dependency

@router.post("/")
async def create_booking(booking: CreateBooking, verified: VerifiedDep) -> ViewBooking | str:
    booking_repository = Dependencies.get(AbstractBookingRepository)
    participant_repository = Dependencies.get(AbstractParticipantRepository)
    user_id = verified.user_id
dantetemplar commented 3 days ago

I have checked all endpoints, everything should be fine.

@ArtemSBulgakov you can make api public