[PR #1756] [MERGED] fix: 403 http error code on failed login #3659

Closed
opened 2026-03-22 14:50:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/1756
Author: @pano9000
Created: 11/6/2025
Status: Merged
Merged: 11/6/2025
Merged by: @kolaente

Base: mainHead: fix_HTTP-error-code-on-failed-login


📝 Commits (2)

  • 4ce832e chore: fix copy/paste error in comment
  • 8f7a92e fix: send 403 http.StatusForbidden for ErrWrongUsernameOrPassword

📊 Changes

1 file changed (+3 additions, -3 deletions)

View changed files

📝 pkg/user/error.go (+3 -3)

📄 Description

Hi,

this PR is doing a minor change to the error code that the API returns back for a failed login, when the wrong username or password is provided.

The swagger docs are reporting to expect a 403 error code, as mentioned here:
5987874165/pkg/routes/api/v1/login.go (L45)

However it was sending actually sending a http.StatusPreconditionFailed (so a 412 code).

With the change it should now send a http.StatusForbidden (so a 403) as documented (and it makes a bit more sense than 412 as well IMHO).

Reason I noticed it:
Was trying to set up fail2ban with a TOTP enabled account, but manually testing discovered, that even when I put in nonsense values in the first "login stage" (i.e. where you enter user + pass, BEFORE you get the TOTP field displayed), I got a 412 back, instead of a 403.

The fail2ban documentation also does not need to be updated, it already assumes 400, 403 and 412 as failure codes.


And while I was at it, I did a tiny copy/paste error correction on some comments


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/1756 **Author:** [@pano9000](https://github.com/pano9000) **Created:** 11/6/2025 **Status:** ✅ Merged **Merged:** 11/6/2025 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `fix_HTTP-error-code-on-failed-login` --- ### 📝 Commits (2) - [`4ce832e`](https://github.com/go-vikunja/vikunja/commit/4ce832e4ca68aa749fbd432ef1d5437baa6062dc) chore: fix copy/paste error in comment - [`8f7a92e`](https://github.com/go-vikunja/vikunja/commit/8f7a92ec1409e41946250161488f0b85ad489ea1) fix: send 403 http.StatusForbidden for ErrWrongUsernameOrPassword ### 📊 Changes **1 file changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `pkg/user/error.go` (+3 -3) </details> ### 📄 Description Hi, this PR is doing a minor change to the error code that the API returns back for a failed login, when the wrong username or password is provided. The swagger docs are reporting to expect a `403` error code, as mentioned here: https://github.com/go-vikunja/vikunja/blob/59878741659c3f5335acd5bdd96842c69ac0778f/pkg/routes/api/v1/login.go#L45 However it was sending actually sending a `http.StatusPreconditionFailed` (so a `412` code). With the change it should now send a `http.StatusForbidden` (so a `403`) as documented (and it makes a bit more sense than `412` as well IMHO). Reason I noticed it: Was trying to set up fail2ban with a TOTP enabled account, but manually testing discovered, that even when I put in nonsense values in the first "login stage" (i.e. where you enter user + pass, BEFORE you get the TOTP field displayed), I got a `412` back, instead of a `403`. The [fail2ban documentation](https://vikunja.io/docs/fail2ban/) also does not need to be updated, it already assumes 400, 403 and 412 as failure codes. ---- And while I was at it, I did a tiny copy/paste error correction on some comments --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-22 14:50:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#3659