Skip to content

Conversation

@rajpatel24
Copy link
Contributor

@rajpatel24 rajpatel24 commented Nov 25, 2025

📣 Summary

Ensure KoboCollect can submit anonymously by returning 204 for HEAD /<username>/submission before applying the empty-request authentication check, while keeping Digest authentication behavior intact.

📖 Description

After adding a guard to return 401 for unauthenticated empty-body POST requests (required for Digest auth handshake), KoboCollect began failing anonymous submissions. KoboCollect performs an initial HEAD request to /<username>/submission to probe server availability. Because the guard ran before the HEAD handler, this probe was incorrectly treated as unauthenticated, returning 401. KoboCollect interprets a 401 on HEAD as "credentials required" and therefore never sends the actual XML payload, showing the login screen instead.

Enketo continued to work because it tolerates a 401 on the first probe, but KoboCollect does not.

👀 Preview steps

  1. ℹ️ Make sure you have an account and a project that allows anonymous submissions.
  2. Configure the KoboCollect Android App to use this project. (Follow this#Kobo Dev > Tools, tips and tricks @ 💬 if you are unsure how to connect KoboCollect with your local setup.)
  3. In the app, add the URL (e.g., http://<your-ip>/username) and leave the username and password fields empty.
  4. This will allow you to download the forms that allow anonymous submissions for this user.
  5. Try submitting data to the form.
  6. 🔴 [On release]: notice that the app shows the login window while the server returns a 401.
  7. 🟢 [On PR]: notice that the data is submitted successfully.
  8. Also, try submitting the data anonymously from the web (Enketo) and confirm that there are no issues.
  9. 🟢 Notice that the digest auth fix introduced in kpi#6428 still works.

@rajpatel24 rajpatel24 changed the title fix(submission): fix anonymous submissions from KoboCollect by handling HEAD before auth checks DEV-1347 fix(submission): fix anonymous submission failures from KoboCollect DEV-1347 Nov 25, 2025
Copy link
Contributor

@rgraber rgraber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rajpatel24 rajpatel24 merged commit 97862a0 into release/2.025.43 Nov 25, 2025
11 checks passed
@rajpatel24 rajpatel24 deleted the dev-1347-fix-failing-anonymous-submissions-from-collect branch November 25, 2025 14:49
duvld pushed a commit that referenced this pull request Nov 26, 2025
… DEV-1347 (#6499)

### 📣 Summary
Ensure `KoboCollect` can submit anonymously by returning 204 for `HEAD
/<username>/submission` before applying the [empty-request
authentication
check](https://github.com/kobotoolbox/kpi/blob/b4b82b809c205dfb0a23eba7633e57f50ac35c6f/kobo/apps/openrosa/apps/api/viewsets/xform_submission_api.py#L253-L257),
while keeping Digest authentication behavior intact.


### 📖 Description
After adding a guard to return `401` for unauthenticated empty-body POST
requests (required for Digest auth handshake), KoboCollect began failing
anonymous submissions. KoboCollect performs an initial HEAD request to
`/<username>/submission` to probe server availability. Because the guard
ran before the HEAD handler, this probe was incorrectly treated as
unauthenticated, returning 401. KoboCollect interprets a 401 on HEAD as
"credentials required" and therefore never sends the actual XML payload,
showing the login screen instead.

Enketo continued to work because it tolerates a 401 on the first probe,
but KoboCollect does not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants