Skip to content

fix(idp): don't report network failures as wrong credentials on login - #13072

Open
paul43210 wants to merge 2 commits into
owncloud:masterfrom
paul43210:fix/idp-login-network-error
Open

paul43210 wants to merge 2 commits into
owncloud:masterfrom
paul43210:fix/idp-login-network-error

Conversation

@paul43210

Copy link
Copy Markdown
Contributor

Description

The built-in IdP login page told users "Invalid username or password" for every failure, including requests that never reached the server. This PR separates the three cases:

  • Wrong credentials (IdP answers 204/401, or success: false): unchanged, "Login failed. Invalid username or password."
  • No answer (fetch rejects with TypeError, or the request is aborted): new ErrFailed text, "Login failed. The server could not be reached. Please check your connection and try again."
  • Server error (any other status): new ErrDefault text, "Login failed. Something went wrong. Please try again."

It also:

  • aborts logon/hello requests after 30 s without an answer (AbortController), so a dropped connection ends in a message instead of a form that waits forever;
  • stops mapping AbortError to the wrong-credentials message;
  • guards result.data before reading result.data.success (a 200 with an empty body threw inside the handler).

Only the two message strings and the inline login script change; no template or API changes.

Related Issue

Motivation and Context

On a production instance behind Apache with a fail2ban jail that bans an address after repeated failed logins, a banned user's further attempts never reach the server, but the page kept saying the password was wrong, so they kept retrying a correct one. The same happens whenever the network drops or the server is down.

How Has This Been Tested?

  • test environment: oCIS master c4a6948a67, Go 1.26 (GOTOOLCHAIN=auto), vendored modules.
  • test case 1: new TestLoginErrorMessagesAreDistinct (services/idp/pkg/service/v0) renders the login page and checks that data-msg-failed and data-msg-default differ from data-msg-invalid, that the script uses AbortController, and that AbortError is not mapped to MSG_INVALID. It fails on the old code for all four reasons and passes with the fix.
  • test case 2: go test ./services/idp/... green.
  • test case 3: node --check on the extracted login script; make changelog-lint clean.
  • test case 4 (behaviour that motivated it): on our 8.2 deployment, a phone banned by fail2ban after 20 failed logins kept seeing the wrong-credentials message on further attempts that never reached Apache (checked in the access log).

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

New strings: the two changed t.Get(...) messages will need translating through the usual Transifex flow.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WpoeSoKYEdgQcWjEzTVKpT

@paul43210
paul43210 requested a review from a team as a code owner October 5, 2026 17:43
@kw-security

kw-security commented Oct 5, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

the IdP (204/401) reports invalid credentials. Login requests now give up
after 30 seconds without an answer.

https://github.com/owncloud/ocis/issues/13071

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please point to the correct issue? It should be 13072 instead of 13071

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, it now links #13072 (f49ac15). Thanks!

@jvillafanez jvillafanez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code looks good to me.
@mzner @LukasHirt do we have any "old browser support" policy? Using the AbortSignal seems a cleaner solution, but it might be too new.

@paul43210
paul43210 force-pushed the fix/idp-login-network-error branch from f49ac15 to 391462e Compare October 9, 2026 00:28
@mzner
mzner self-requested a review October 9, 2026 08:02
Comment thread services/idp/pkg/service/v0/service.go Resolved
@mmattel

mmattel commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@paul43210 please also rebase because we have updated some tests for improved checking.

paul43210 added a commit to paul43210/ocis that referenced this pull request Oct 18, 2026
Review feedback on owncloud#13072: the login page's catch block also ran for errors
in the page's own code, which would then have read "The server could not be
reached".

- fetchApi now tags its own rejections with err.kind: "timeout" when the
  30 s timer aborted the request, "network" when it never reached the server.
- New ErrTimeout message: "The server did not answer in time. Please try
  again."
- ErrFailed is shown only for network failures; any other exception falls
  through to the generic ErrDefault.
- Use optional chaining for result.data, the abort signal and err.kind.

TestLoginErrorMessagesAreDistinct also checks that the timeout, failed and
default messages differ and that the page branches on the kind; it fails on
the previous catch block.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Paul Faure <paul@faure.ca>
@paul43210
paul43210 force-pushed the fix/idp-login-network-error branch from 391462e to 01e1b0a Compare October 18, 2026 04:25
@paul43210

Copy link
Copy Markdown
Contributor Author

Rebased onto master (d2d82ba) as asked, @mmattel. @LukasHirt's three points are addressed in 01e1b0a (replies inline). @mzner, the changelog link you flagged was fixed earlier (it points to this PR). Could you re-review when you have a moment?

@mzner

mzner commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Rebased onto master (d2d82ba) as asked, @mmattel. @LukasHirt's three points are addressed in 01e1b0a (replies inline). @mzner, the changelog link you flagged was fixed earlier (it points to this PR). Could you re-review when you have a moment?

@paul43210 So sorry for the late reply. Looks good to me. Could you please rebase and push again?

paul43210 added a commit to paul43210/ocis that referenced this pull request Nov 17, 2026
Review feedback on owncloud#13072: the login page's catch block also ran for errors
in the page's own code, which would then have read "The server could not be
reached".

- fetchApi now tags its own rejections with err.kind: "timeout" when the
  30 s timer aborted the request, "network" when it never reached the server.
- New ErrTimeout message: "The server did not answer in time. Please try
  again."
- ErrFailed is shown only for network failures; any other exception falls
  through to the generic ErrDefault.
- Use optional chaining for result.data, the abort signal and err.kind.

TestLoginErrorMessagesAreDistinct also checks that the timeout, failed and
default messages differ and that the page branches on the kind; it fails on
the previous catch block.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Paul Faure <paul@faure.ca>
@paul43210
paul43210 force-pushed the fix/idp-login-network-error branch from 01e1b0a to 931bb91 Compare November 17, 2026 19:42
@mmattel

mmattel commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

The build-and-test CI job is failing because a security-related fix that was applied to master is missing on this branch. A rebase onto the current master will pick it up and unblock CI.

git fetch origin
git rebase origin/master
git push --force-with-lease

paul43210 and others added 2 commits November 18, 2026 19:32
The login page used the same text, "Invalid username or password", for
ErrInvalid, ErrFailed and ErrDefault, mapped an aborted request to the
wrong-credentials message, and had no timeout on the logon request. A user
whose request never reached the server (network down, connection blocked
by a firewall or a fail2ban ban) was told the password was wrong and kept
retrying a correct one.

- ErrFailed: "The server could not be reached. Please check your connection
  and try again." (network errors and timeouts)
- ErrDefault: "Something went wrong. Please try again." (server errors)
- ErrInvalid is unchanged and is only shown for the IdP's credential
  rejections (204/401).
- Logon and hello requests now abort after 30 s without an answer.
- Guard result.data before reading result.data.success.

TestLoginErrorMessagesAreDistinct fails on the old code for all four
reasons and passes now.

Fixes owncloud#13071

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Paul Faure <paul@faure.ca>
Review feedback on owncloud#13072: the login page's catch block also ran for errors
in the page's own code, which would then have read "The server could not be
reached".

- fetchApi now tags its own rejections with err.kind: "timeout" when the
  30 s timer aborted the request, "network" when it never reached the server.
- New ErrTimeout message: "The server did not answer in time. Please try
  again."
- ErrFailed is shown only for network failures; any other exception falls
  through to the generic ErrDefault.
- Use optional chaining for result.data, the abort signal and err.kind.

TestLoginErrorMessagesAreDistinct also checks that the timeout, failed and
default messages differ and that the page branches on the kind; it fails on
the previous catch block.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Paul Faure <paul@faure.ca>
@paul43210
paul43210 force-pushed the fix/idp-login-network-error branch from 931bb91 to 23959df Compare November 19, 2026 01:05
@paul43210

Copy link
Copy Markdown
Contributor Author

Rebased onto master (37a8944) as asked, @mmattel; idp tests pass. Head is now 23959df. Thanks @mzner and @LukasHirt for the approvals.

@mzner
mzner enabled auto-merge (squash) November 19, 2026 06:30

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IdP login page reports network failures as "Invalid username or password"

6 participants