Skip to content

Security P2 — Close unauthenticated routes: practice, nudges, jobs (+WS) #62

Description

@franciszver

Part of #59.

Part of the broken-access-control remediation epic. Depends on Phase 1. Highest severity — these routes require no authentication at all today.

Findings addressed

Work

  • Switch these handlers from get_current_user_optional to mandatory get_current_user.
  • Apply the Phase‑1 helper against the resolved DB user for each student_id/item_id/nudge_id.
  • For jobs.py: record owner (Job.user_id/student_id already exist) and check it; authenticate the WS on connect (token via query param or subprotocol) before streaming.

Definition of Done

  • All routes reject unauthenticated requests (401).
  • Cross-user access returns 403 (Phase‑1 tests green for these routes).
  • WS closes unauthenticated/unauthorized connections before sending any data.

Affected files

src/api/handlers/practice.py, src/api/handlers/nudges.py, src/api/handlers/jobs.py, src/api/middleware/auth.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions