Skip to content

[BACKEND] All HTTP endpoints bypass authentication entirely #372

@Hydrax117

Description

@Hydrax117

Description:
Every single HTTP handler contains this placeholder pattern:

// TODO: Extract user ID from JWT token
let user_id = Uuid::new_v4(); // Placeholder - should come from auth middleware

This means every request — score reporting, dispute creation, tournament creation, matchmaking, and Elo queries — is processed with a randomly generated UUID as the caller's identity. There is zero authentication enforcement anywhere in the request pipeline despite JwtService being fully implemented.

Affected files:

  • src/http/matches.rs — all 9 handlers
  • src/http/tournaments.rs — all 7 handlers

Steps to reproduce: Send any POST to /api/matches/{id}/report without an Authorization header. The request is accepted and processed.

Expected behavior: Requests without a valid Authorization: Bearer <token> header must be rejected with 401 Unauthorized.

Proposed fix:

  1. Create an Actix-Web FromRequest extractor that reads the Authorization header, calls JwtService::validate_token, and returns Claims.
  2. Inject JwtService as web::Data<Arc<Mutex<JwtService>>> in main.rs.
  3. Replace every let user_id = Uuid::new_v4() with claims.sub.parse::<Uuid>().
  4. Apply the extractor to all protected routes.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions