Skip to content

feat(problem): add IP-auth submission API endpoint#448

Open
whlongg wants to merge 7 commits intoVNOI-Admin:masterfrom
whlongg:feat/ip-auth-problem-api
Open

feat(problem): add IP-auth submission API endpoint#448
whlongg wants to merge 7 commits intoVNOI-Admin:masterfrom
whlongg:feat/ip-auth-problem-api

Conversation

@whlongg
Copy link
Contributor

@whlongg whlongg commented Oct 1, 2025

Description

Type of change: new feature

What

  • Add a CSRF-exempt /problem/<code>/api_submit view for trusted IP-authenticated clients, reusing the existing submission pipeline while returning JSON.
  • Introduce language-extension preference mapping and a helper to pick the best match when inferring the language from uploaded files.
  • Inline non–file-only submissions as source text, leaving file uploads only for file-only languages, so API judging mirrors the UI flow.
  • Register the new endpoint in site/dmoj/urls.py without affecting the classic /submit.

Why

To provide an official form-data submission API for IP-based authentication users while keeping the current UI behaviour untouched.

Fixes #

How Has This Been Tested?

  • Test A – Manual UI submission (browser) succeeds and still requires CSRF.
  • Test B – curl -F submission_file=@aplusb.cpp http://0.0.0.0:8000/problem/aplusb/api_submit from an IP-auth session returns {"id": ...} and judges correctly; the same request from a non IP-auth session returns the expected JSON 403.

Checklist

  • I have explained the purpose of this PR.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the README/documentation
  • Any dependent changes have been merged and published in downstream modules
  • Informed of breaking changes, testing and migrations (if applicable).
  • Attached screenshots (if applicable).

By submitting this pull request, I confirm that my contribution is made under the terms of the AGPL-3.0 License.

@magnified103 magnified103 linked an issue Dec 15, 2025 that may be closed by this pull request
@magnified103 magnified103 self-requested a review December 15, 2025 11:46
@whlongg
Copy link
Contributor Author

whlongg commented Jan 24, 2026

@leduythuccs The branch has been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant